-
Notifications
You must be signed in to change notification settings - Fork 863
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
feat: add a DynamoDBContextBuilder to construct a DynamoDBContext #3430
Conversation
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 would like to see unit test coverage for the different methods that build the context based upon a provided client, region, and configuration. Are these somewhere that I missed?
The constructed |
sdk/src/Services/DynamoDBv2/Custom/DataModel/IDynamoDBContextBuilder.cs
Outdated
Show resolved
Hide resolved
namespace Amazon.DynamoDBv2.DataModel | ||
{ | ||
/// <summary> | ||
/// Interface for a builder that constructs a <see cref="DynamoDBContext"/> |
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.
Add would suggest giving more context for users upgrading about how this newer approach disables the DescribeTable
mechanism. And explain how the can use the ConfigureContext
method to revert to pervious behavior if they need it.
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 more docs in the interface and inheritor.
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.
Add a line that says alternatively to attributes on the class you can register the table definition using the RegisterTableDefinition
method on the context object.
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.
Done
sdk/src/Services/DynamoDBv2/Custom/DataModel/IDynamoDBContextBuilder.cs
Outdated
Show resolved
Hide resolved
sdk/src/Services/DynamoDBv2/Custom/DataModel/IDynamoDBContextBuilder.cs
Outdated
Show resolved
Hide resolved
namespace Amazon.DynamoDBv2.DataModel | ||
{ | ||
/// <summary> | ||
/// Interface for a builder that constructs a <see cref="DynamoDBContext"/> |
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.
Add a line that says alternatively to attributes on the class you can register the table definition using the RegisterTableDefinition
method on the context object.
|
||
namespace Amazon.DynamoDBv2.DataModel | ||
{ | ||
/// <summary> |
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.
Do you want to use <inheritdoc/>
instead of duplicating this large comment block?
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.
Done
cb4fabc
to
f34782e
Compare
I rebased on top of |
f34782e
to
d36dd11
Compare
d36dd11
to
857b165
Compare
To build the low level DynamoDB requests from both high-level programming models, the SDK requires knowledge of the table and index key structure. It generally relies on an internal call to
DescribeTable
. This call may invoked from synchronous public APIs, which relies on the sync-over-async antipattern for versions of .NET that only have an async HTTP client. This can lead to performance issues and deadlocks.In October 2023 we released new initializers for users to provide the table and index structure on the client and skip the
DescribeTable
call.Description
The aim of this PR is to mark the methods that reply on sync-over-async calls as
[Obsolete]
in order to encourage users to use the newTableBuilder
for the Document model, as well as the newDynamoDBContextBuilder
, which is introduced in this PR, for the object-persistence model.For the document model, this PR obsoletes all the
LoadTable
andTryLoadTable
calls.For the object-persistence model, this PR adds a new
DynamoDBContextBuilder
which constructs aDynamoDBContext
that setsDisableFetchingTableMetadata
totrue
by default.Motivation and Context
This change is required to mode customers away from sync-over-async calls which have lead to performance issues and deadlocks in the past.
Testing
For testing, I have added new tests that use the new
DynamoDBContextBuilder
to create theDynamoDBContext
and I left some tests that create theDynamoDBContext
using the old way.I have ran all the tests locally and they have passed.
Types of changes
Checklist
License