-
Notifications
You must be signed in to change notification settings - Fork 113
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
Conversation
5ea74b3
to
792189b
Compare
self = .string(value) | ||
case "Number": | ||
let value = try container.decode(AWSNumber.self, forKey: .stringValue) | ||
self = .number(value) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- 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.
- 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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these in use?
There was a problem hiding this comment.
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) | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
4c26e48
to
287f235
Compare
287f235
to
1e35d1d
Compare
Sources/AWSLambdaEvents/SQS.swift
Outdated
self.awsRegion = try container.decode(AWSRegion.self, forKey: .awsRegion) | ||
|
||
let body = try container.decode(String?.self, forKey: .body) | ||
self.body = body != "" ? body : nil |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see proposal in 4b10997
No description provided.