Skip to content

Added SNS & SQS Events #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 3, 2020
Merged

Added SNS & SQS Events #46

merged 7 commits into from
Apr 3, 2020

Conversation

fabianfett
Copy link
Member

No description provided.

@fabianfett fabianfett requested a review from tomerd March 25, 2020 09:34
self = .string(value)
case "Number":
let value = try container.decode(AWSNumber.self, forKey: .stringValue)
self = .number(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should .number just be the numeric value instead of the AWSNumber decoding envelope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't thought about this so far. Tried it today and ran into two issues:

  1. Protocol 'Numeric' can only be used as a generic constraint because it has Self or associated type requirements.
  public enum Attribute {
    case string(String)
    case binary([UInt8])
    case number(Numeric)
}

I don't think we should make Attribute generic.

  1. Even if this was working, how would we parse the number in this case? Try to parse into Int and if that doesn't work parse into Double?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking the enum option will include int and double instead of generic number. wdyt?

Copy link
Member Author

@fabianfett fabianfett Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds reasonable, but we would not use the original data format which by itself is just a plain String. Anyway, how would we parse this? Try Int first? If this doesn't work try to parse Double? Your call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomerd do you have any input on this?

Copy link
Contributor

@tomerd tomerd Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear, I was not pushing against using AWSNumber for decoding, but against "leaking" it in the enum. I guess you are asking if we should first try AWSNumber's double accessor or the int accessor first to determine how to populate the enum?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I can follow you in not wanting to not the leak the AWSNumber type. Do you have an idea in mind how you would like to achieve this?

Package.swift Outdated
.target(name: "AWSLambdaEvents", dependencies: []),
.target(name: "AWSLambdaEvents", dependencies: [
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these in use?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upps. Forgot to remove when I was cherry picking. Fixed.

// of four.
try Base64.decode(encoded: self, options: options)
}
}
Copy link
Contributor

@tomerd tomerd Mar 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we missing the tests for the base64 utility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

self.awsRegion = try container.decode(AWSRegion.self, forKey: .awsRegion)

let body = try container.decode(String?.self, forKey: .body)
self.body = body != "" ? body : nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required? ie synthesized decoding not working?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see proposal in 4b10997

@fabianfett fabianfett mentioned this pull request Apr 1, 2020
@tomerd tomerd merged commit 7a94606 into master Apr 3, 2020
@tomerd tomerd deleted the sns-and-sqs-event branch April 3, 2020 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants