-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Enhancing CosmosTemplate to Support Multi-Tenancy at a Container Level #33400
Enhancing CosmosTemplate to Support Multi-Tenancy at a Container Level #33400
Conversation
…level Spring multitenant container level
API change check APIView has identified API level changes in this PR and created following API reviews. |
* @param cosmosAsyncClient cosmosAsyncClient | ||
* @param databaseName databaseName | ||
*/ | ||
public MultiTenantContainerCosmosFactory(CosmosAsyncClient cosmosAsyncClient, String databaseName) { |
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.
just curious, why we do not have an constructor accepting containerName? and also in Spring, we do not really use setter pattern?
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.
By default, container name is taken from either entity name, or containerName in @container within entity if defined. So it need not be passed to the constructor by default (but we add the setter/getter here so it can be overridden and called polymorphically in the case of multi-tenant scenario). For databaseName, this has to be passed in, as that has to be defined in config. For getter/setter, yes we should, but these are just sample classes to facilitate the unit tests, and will only be used by them, they are not part of the API (user would create their own, and we'll have examples for that in samples repo).
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.
LGTM, thanks :)
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.
LGTM thanks
Description
This PR adds support for multi-tenancy at a container level via the CosmosFactory. There is a test case added which shows how the user can extend CosmosFactory and use overrideContainerName() in order to dynamically set the container being used by CosmosTemplate and repositories when making calls. Integration test coverage was added for this new feature. Reactive tests are also added for container and database level multitenancy (see PR #32516).
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines