-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: avoid instantiating DocumentClient
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.
- Loading branch information
Showing
3 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters