serverless-api-example icon indicating copy to clipboard operation
serverless-api-example copied to clipboard

Is it intentional that the ddb client is never closed?

Open theonlyalterego opened this issue 4 years ago • 2 comments

It looks like the Init() in users is being called once when the service is started. Which seems to create one client, which is never closed, but is just re-used for all future hits on the route.

Is this intended?

I had expected the client to be created on demand, and then released when finished.

I'm new to go, and interested in understanding this implementation.

theonlyalterego avatar Oct 01 '19 20:10 theonlyalterego

Hmm let's do some digging!

Client as in the AWS client? The DynamoDB client?

EwanValentine avatar Oct 04 '19 08:10 EwanValentine

the dynamo client. in other code examples I have seen typically you defer closing the client once you're done with it. in your code it seems you're never done with the client, it just remains available for future calls to each endpoint.

theonlyalterego avatar Oct 28 '19 17:10 theonlyalterego