Skip to content
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

Use different serializer settings with the same client instance #3341

Open
aelij opened this issue Jul 12, 2022 · 0 comments
Open

Use different serializer settings with the same client instance #3341

aelij opened this issue Jul 12, 2022 · 0 comments
Labels
feature-request New feature or request LINQ QUERY

Comments

@aelij
Copy link
Member

aelij commented Jul 12, 2022

Is your feature request related to a problem? Please describe.
Currently specifying a custom serializer (or serialization settings) is only possible at the CosmosClient level.
However, we have many scenarios where we need to use different serialization settings for each request.
It's highly encouraged to use single instance clients:

Its recommended to maintain a single instance of CosmosClient per lifetime of the application which enables efficient connection management and performance

Each DocumentClient instance is thread-safe and performs efficient connection management and address caching when operating in direct mode. To allow efficient connection management and better SDK client performance, we recommend that you use a single instance per AppDomain for the lifetime of the application.

While it is possible to use Stream based APIs for some usages to circumvent this limitation, it is not possible to use with LINQ (GetItemLinqQueryable) which is our primary API.

Describe the solution you'd like
Allow changing the custom serializer / settings after the client is created. Either of these would work well for our scenarios:

  • CosmosClient.WithSerializer(CosmosSerializer, CosmosSerializerOptions) - returns a new instance of the client that utilizes the same connection but with a different serializer
  • CosmosClient.GetContainer(CosmosSerializer, CosmosSerializerOptions) - same as above, but at the container level

Describe alternatives you've considered
Use multiple CosmosClient instances.

@ealsur ealsur added feature-request New feature or request QUERY LINQ labels Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request LINQ QUERY
Projects
Status: Triage
Development

No branches or pull requests

2 participants