-
Notifications
You must be signed in to change notification settings - Fork 862
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 the Context/Operation Config Hierarchy, and Remove Table-level Configurations from DynamoDBOperationConfig #3422
Remove the Context/Operation Config Hierarchy, and Remove Table-level Configurations from DynamoDBOperationConfig #3422
Conversation
@@ -152,12 +162,6 @@ public DynamoDBContextConfig() | |||
#endif | |||
public class DynamoDBOperationConfig : DynamoDBContextConfig |
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.
Should we break this hierarchy while we're here?
We're discouraging the use of DynamoDBOperationConfig
in V4 via [Obsolete]
#3421, but this did lead to the confusion that this is addressing in the first place.
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 think it make sense to break the hierarchy. I assume we would copy over the properties from DynamoDBContextConfig to DynamoDBOperationConfig that made sense at the operation level.
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 in f478a1b
/// If you specify this on <see cref="DynamoDBContextConfig"/>, then it will apply to all | ||
/// objects/tables used with that <see cref="DynamoDBContext"/> object unless overriden by an operation-specific config. | ||
/// </remarks> | ||
public string OverrideTableName { get; set; } |
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.
Having this property on the context's config doesn't make sense to me since the context works with multiple tables. I know you call that out in the doc that it replaces all table mappings. I'm thinking it was a failure in our response to the GitHub issues to not point out that could accomplish what they wanted using the AWSConfigsDynamoDB.Context.TypeMappings
property. Here is how I configured one of my application to use the table that was created during deployment as part of CloudFormation with CloudFormation naming the table.
var tableName = System.Environment.GetEnvironmentVariable(ENV_TABLE_NAME_POLL_DEFINITION);
if (!string.IsNullOrEmpty(tableName))
{
PollDefinitionTableName = tableName;
AWSConfigsDynamoDB.Context.TypeMappings[typeof(PollDefinition)] = new Amazon.Util.TypeMapping(typeof(PollDefinition), tableName);
Console.WriteLine($"Using table {tableName} for PollDefinition");
}
If we really want this capability on the context object I think we would have to make it a map of types to table names.
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 wasn't too attached to this yet either, was mostly throwing it out there since there seems to be interest via the three issues. The only counterargument I can think of is if an application is only working with a single table, the current approach is simpler to override.
Should we just point users to AWSConfigsDynamoDB.Context.TypeMappings
? and then break the hierarchy so it stops looking like you could be able to do this? Or maybe we can leave this PR out for a bit for feedback, I could go comment on the original issues.
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.
Yeah I think we should point users to AWSConfigsDynamoDB.Context.TypeMappings
. You are right that the single property would be useful in a single table design but then confusing in the other case. I don't have a feeling how common single table design is but I don't believe it would be the overwhelming majority to warrant putting in this confusing property for non single table users.
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.
You could add a comment on the OverrideTableName
for the operational config that if users want to make the override global they should use the AWSConfigsDynamoDB.Context.TypeMappings
.
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 in f478a1b.
Plus as long as we do the breaking change to separate the hierarchy in V4, if we did want to add a context-level table mapping, that'd be an additive change in the future.
@@ -152,12 +162,6 @@ public DynamoDBContextConfig() | |||
#endif | |||
public class DynamoDBOperationConfig : DynamoDBContextConfig |
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 think it make sense to break the hierarchy. I assume we would copy over the properties from DynamoDBContextConfig to DynamoDBOperationConfig that made sense at the operation level.
7236fff
to
f478a1b
Compare
/// If you want to specify this globally instead of for each operation, you can use | ||
/// the <see cref="TableAlias"/> or <see cref="TypeMapping"/> collections | ||
/// on <see cref="AWSConfigsDynamoDB.Context"/>. | ||
/// </remarks> |
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.
New note the suggests an alternative to the operation-level override.
/// table metadata. It requires that the table's index schema be accurately described via the above methods, | ||
/// otherwise exceptions may be thrown and/or the results of certain DynamoDB operations may change. | ||
/// </remarks> | ||
public bool? DisableFetchingTableMetadata { get; set; } |
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.
Does this make sense at the operational level? Since only one operation invoke is going to do the cache load for a table would a user even now when the load is happening or not.
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.
Maybe that's why I left it off originally... Agreed that you wouldn't need to set this past the first one.
I can remove it again, especially in parallel with #3430
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 in 295e52e
/// For <see cref="MetadataCachingMode.TableNameOnly"/> the cache key will only consist of the table name. This reduces cache misses in contexts | ||
/// where you are accessing tables with identical structure but using different credentials or endpoints (such as a multi-tenant application). | ||
/// </remarks> | ||
public MetadataCachingMode? MetadataCachingMode { get; set; } |
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.
Like DisableFetchingTableMetadata
this property doesn't make sense at the operational level.
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 in 295e52e
… specified on a DynamoDBOperationConfig, instead of just on the DynamoDBContextConfig
295e52e
to
cd2e44a
Compare
Description
This allows users to setOverrideTableName
on theDynamoDBContextConfig
, not just theDynamoDBOperationConfig
While I was here I noticed that I didn't follow the hierarchy when addingDisableFetchingTableMetadata
last year, so backfilled that too.New changes after PR feedback:
DynamoDBContextConfig
andDynamoDBOperationConfig
, to remove the appearance that you can pass an operation config into the context. This came up several times withOverrideTableName
.DynamoDBOperationConfig
(and thus all of the new operation-specific config objects). These control how the context object caches table metadata, and should be specified there instead of at the operation level.Motivation and Context
We've gotten a few requests over the years for the ability to override the DynamoDB table name via the object-persistence context config, instead of needing to do so on every operation config.
This is complicated by the fact that
DynamoDBOperationConfig
inherits fromDynamoDBContextConfig
. One could be passing an operation config into the context constructor, thinking thatOverrideTableName
would apply.aws-sdk-net/sdk/src/Services/DynamoDBv2/Custom/DataModel/Configs.cs
Line 153 in 2b0190e
Testing
Types of changes
Checklist
License