-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding TransactionalBatchRequestOption and test cases
Signed-off-by: Rakesh Kumar <[email protected]>
- Loading branch information
Showing
11 changed files
with
291 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchRequestOption.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using Microsoft.Azure.Documents; | ||
|
||
/// <summary> | ||
/// Cosmos batch request options | ||
/// </summary> | ||
public class TransactionalBatchRequestOption : RequestOptions | ||
{ | ||
/// <summary> | ||
/// Gets or sets the consistency level required for the request in the Azure Cosmos DB service. | ||
/// </summary> | ||
/// <value> | ||
/// The consistency level required for the request. | ||
/// </value> | ||
/// <remarks> | ||
/// Azure Cosmos DB offers 5 different consistency levels. Strong, Bounded Staleness, Session, Consistent Prefix and Eventual - in order of strongest to weakest consistency. <see cref="ConnectionPolicy"/> | ||
/// <para> | ||
/// While this is set at a database account level, Azure Cosmos DB allows a developer to override the default consistency level | ||
/// for each individual request. | ||
/// </para> | ||
/// </remarks> | ||
public ConsistencyLevel? ConsistencyLevel | ||
{ | ||
get => this.BaseConsistencyLevel; | ||
set => this.BaseConsistencyLevel = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the boolean to only return the headers and status code in | ||
/// the Cosmos DB response for operations in the transactional batch request. | ||
/// This removes the resource from the response. This reduces networking and CPU load by not sending | ||
/// the resource back over the network and serializing it on the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is optimal for workloads where the returned resource is not used. | ||
/// </remarks> | ||
public bool? EnableContentResponseOnOperations { get; set; } | ||
|
||
/// <summary> | ||
/// Fill the CosmosRequestMessage headers with the set properties | ||
/// </summary> | ||
/// <param name="request">The <see cref="RequestMessage"/></param> | ||
internal override void PopulateRequestOptions(RequestMessage request) | ||
{ | ||
if (this.EnableContentResponseOnOperations.HasValue && | ||
!this.EnableContentResponseOnOperations.Value) | ||
{ | ||
request.Headers.Add(HttpConstants.HttpHeaders.Prefer, HttpConstants.HttpHeaderValues.PreferReturnMinimal); | ||
} | ||
|
||
base.PopulateRequestOptions(request); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.