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

Change Feed Processor: Fixes initialization when client is set with EnableContentResponseOnWrite #2436

Merged
merged 5 commits into from
Apr 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
optimizing
  • Loading branch information
ealsur committed Apr 29, 2021
commit 9954d6a1242527c179944650981bb91e45f13cec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Utils

internal static class CosmosContainerExtensions
{
private static readonly ItemRequestOptions itemRequestOptionsWithResponseEnabled = new ItemRequestOptions()
{
EnableContentResponseOnWrite = false
};

public static readonly CosmosSerializerCore DefaultJsonSerializer = new CosmosSerializerCore();

public static async Task<T> TryGetItemAsync<T>(
Expand All @@ -38,7 +43,7 @@ public static async Task<ItemResponse<T>> TryCreateItemAsync<T>(
{
using (Stream itemStream = CosmosContainerExtensions.DefaultJsonSerializer.ToStream<T>(item))
{
using (ResponseMessage response = await container.CreateItemStreamAsync(itemStream, partitionKey).ConfigureAwait(false))
using (ResponseMessage response = await container.CreateItemStreamAsync(itemStream, partitionKey, itemRequestOptionsWithResponseEnabled).ConfigureAwait(false))
{
if (response.StatusCode == HttpStatusCode.Conflict)
{
Expand All @@ -47,6 +52,7 @@ public static async Task<ItemResponse<T>> TryCreateItemAsync<T>(
}

response.EnsureSuccessStatusCode();

return new ItemResponse<T>(
response.StatusCode,
response.Headers,
Expand All @@ -65,6 +71,7 @@ public static async Task<ItemResponse<T>> TryReplaceItemAsync<T>(
{
using (Stream itemStream = CosmosContainerExtensions.DefaultJsonSerializer.ToStream<T>(item))
{
itemRequestOptions.EnableContentResponseOnWrite = false;
using (ResponseMessage response = await container.ReplaceItemStreamAsync(itemStream, itemId, partitionKey, itemRequestOptions).ConfigureAwait(false))
{
response.EnsureSuccessStatusCode();
Expand Down