-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remove dependency on AWS-SDK #29
Comments
This partially addresses the problem raised in issue tuplo#29. It allows for consumers to reliably load only their own AWS SDK version rather than risking potentially bundling multiple copies in a build. It also makes this package more Lambda function friendly, since the aws-sdk version is vended by the runtime by default and does not need to be packaged in. Note that this change does not make this package agnostic to the choice between AWS SDK v2 and v3. The current implementation still relies on imports that exist on v2 but not v3.
This refactor avoids instantiating a DynamoDB.DocumentClient object (which in turn would instantiate an underlying DynamoDB service client) by accessing the `createSet` method from the prototype directly. The interface for `createSet` is: ```typescript createSet(list: number[]|string[]|DocumentClient.binaryType[], options?: DocumentClient.CreateSetOptions): DocumentClient.DynamoDbSet; ``` And the implementation is: ```typescript createSet: function(list, options) { options = options || {}; return new DynamoDBSet(list, options); } ``` As we can see, there is no reliance on the `this` instance, so calling the method from the prototype with an undefined `this` value should work fine. It would have perhaps been preferred to utilize the `DynamoDBSet` class directly, but that is marked with `@private` annotations within the AWS SDK while the `createSet` method on DocumentClient is part of the public API. Aside from the removal of client instantiation, this change also scopes imports to just the DynamoDB specific resources. This has been measured to improve performance by several milliseconds in Lambda runtimes. This somewhat relates to issue tuplo#29, but it doesn't really address it.
This partially addresses the problem raised in issue tuplo#29. It allows for consumers to reliably load only their own AWS SDK version rather than risking potentially bundling multiple copies in a build. It also makes this package more Lambda function friendly, since the aws-sdk version is vended by the runtime by default and does not need to be packaged in. Note that this change does not make this package agnostic to the choice between AWS SDK v2 and v3. The current implementation still relies on imports that exist on v2 but not v3.
This partially addresses the problem raised in issue #29. It allows for consumers to reliably load only their own AWS SDK version rather than risking potentially bundling multiple copies in a build. It also makes this package more Lambda function friendly, since the aws-sdk version is vended by the runtime by default and does not need to be packaged in. Note that this change does not make this package agnostic to the choice between AWS SDK v2 and v3. The current implementation still relies on imports that exist on v2 but not v3.
Now that the |
This refactor avoids instantiating a DynamoDB.DocumentClient object (which in turn would instantiate an underlying DynamoDB service client) by accessing the `createSet` method from the prototype directly. The interface for `createSet` is: ```typescript createSet(list: number[]|string[]|DocumentClient.binaryType[], options?: DocumentClient.CreateSetOptions): DocumentClient.DynamoDbSet; ``` And the implementation is: ```typescript createSet: function(list, options) { options = options || {}; return new DynamoDBSet(list, options); } ``` As we can see, there is no reliance on the `this` instance, so calling the method from the prototype with an undefined `this` value should work fine. It would have perhaps been preferred to utilize the `DynamoDBSet` class directly, but that is marked with `@private` annotations within the AWS SDK while the `createSet` method on DocumentClient is part of the public API. Aside from the removal of client instantiation, this change also scopes imports to just the DynamoDB specific resources. This has been measured to improve performance by several milliseconds in Lambda runtimes. This somewhat relates to issue tuplo#29, but it doesn't really address it.
This refactor avoids instantiating a DynamoDB.DocumentClient object (which in turn would instantiate an underlying DynamoDB service client) by accessing the `createSet` method from the prototype directly. The interface for `createSet` is: ```typescript createSet(list: number[]|string[]|DocumentClient.binaryType[], options?: DocumentClient.CreateSetOptions): DocumentClient.DynamoDbSet; ``` And the implementation is: ```typescript createSet: function(list, options) { options = options || {}; return new DynamoDBSet(list, options); } ``` As we can see, there is no reliance on the `this` instance, so calling the method from the prototype with an undefined `this` value should work fine. It would have perhaps been preferred to utilize the `DynamoDBSet` class directly, but that is marked with `@private` annotations within the AWS SDK while the `createSet` method on DocumentClient is part of the public API. Aside from the removal of client instantiation, this change also scopes imports to just the DynamoDB specific resources. This has been measured to improve performance by several milliseconds in Lambda runtimes. This somewhat relates to issue #29, but it doesn't really address it.
One gotcha is that this lib will currently only work with AWS SDK v2. It's not compatible with v3 because of different imports needed. There are four options, I think:
|
I would love to see a v3 compatible version of this library. We personally use it quite heavily and are trying to remove deps on v2 aws-sdk versions. |
ok, let me look into this. I favor option 3 on @bilalq post, what you guys think? |
Yeah option 3 sounds good to me. |
I just pushed v3 which no longer depends on AWS SDK. import { DocumentClient } from "aws-sdk/clients/dynamodb";
const params = dynoexpr({
DocumentClient,
Update: {
Color: new Set(['Orange', 'Purple'])
},
}) Let me know if it works for you. All types are prefixed with |
We're only using the AWS-SDK to create a DynamoDBSet. Let's try and emulate it and drop the dependency
The text was updated successfully, but these errors were encountered: