Skip to content

Added DynamoDB Event #65

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 4 commits into from
May 7, 2020
Merged

Added DynamoDB Event #65

merged 4 commits into from
May 7, 2020

Conversation

fabianfett
Copy link
Member

No description provided.


extension DynamoDB {
public struct Decoder {
@usableFromInline var userInfo: [CodingUserInfoKey: Any] = [:]
Copy link
Contributor

Choose a reason for hiding this comment

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

@usableFromInline needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

if we want to have this call inlined: yes

        @inlinable public func decode<T: Decodable>(_ type: T.Type, from value: AttributeValue)
            throws -> T
        {
            let decoder = _DecoderImpl(userInfo: userInfo, from: value, codingPath: [])
            return try decoder.decode(T.self)
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

right, I had a conversation with @weissi a while back on the effectiveness of @inlinable in certain uses case. he may have an opinion here as well

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, it's the right call because it's generic and we may be able to inline enough for the whole thing to get specialised. I doubt it'll actually fully work in this case but that's not a good reason not to try.

As a thought for Lambda though: You may just want to recommend -Xswiftc -cross-module-optimization which then makes all those @inlinable/@usableFromInlines superfluous.

}
}

@usableFromInline internal struct _DecoderImpl: Swift.Decoder {
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit of duplication between the different containers, tho not sure if worth making DRYer. your call.

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

one question for @weissi re inlining, otherwise LGTM

@tomerd tomerd merged commit 29d6317 into master May 7, 2020
@tomerd tomerd deleted the dynamodb-event branch May 7, 2020 16:05
tomerd pushed a commit that referenced this pull request May 7, 2020
motivation: support DynamoDB triggers

changes: added DynamoDB Event abstractions and encoders/decoders
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.

3 participants