-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ChangeFeedRequestOptions Refactor (#1332)
* made it so that it is clear that ifmatchetag and ifnonematchetag are not used * added start from types * added visitor * added visitors * wired throughout the codebase * set explicit default * fixed tests * fixed tests * resolved iteration comments * merged * fixed tests * updated preview API * more preview build errors * more build issues * grr * fixed tests * fixed build * added feed range to feed options to remove duplicated state * preview build * fixed NRE * preview build * asdf * fixed preview build errors * need to investigate why there are test failures * fixed request options tests * asdf * need to investigate in a clean brach * need to figure out what is wrong with the continuation token * fixed some tests * fixed XML comments * fixed infinite loop * need to investigate some changes * fixed one test * fixed continuation token bug * added clone method * fixed continuation token bug in standbyfeediterator * fixed another continuaiton token bug * need to remove because of start time * fixed test that needed to start from the begining * need to investigate this on master * updated continuation token * fixed diagnostics scope
- Loading branch information
1 parent
58e2ebb
commit 2a8020f
Showing
44 changed files
with
1,081 additions
and
717 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
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
35 changes: 35 additions & 0 deletions
35
...re.Cosmos/src/FeedRange/FeedRanges/FeedRangeContinuationRequestMessagePopulatorVisitor.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,35 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// ------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Visitor to populate RequestMessage headers and properties based on FeedRange. | ||
/// </summary> | ||
internal sealed class FeedRangeContinuationRequestMessagePopulatorVisitor : IFeedRangeContinuationVisitor | ||
{ | ||
private readonly RequestMessage request; | ||
private readonly Action<RequestMessage, string> fillContinuation; | ||
|
||
public FeedRangeContinuationRequestMessagePopulatorVisitor(RequestMessage request, Action<RequestMessage, string> fillContinuation) | ||
{ | ||
this.request = request ?? throw new ArgumentNullException(nameof(request)); | ||
this.fillContinuation = fillContinuation ?? throw new ArgumentNullException(nameof(fillContinuation)); | ||
} | ||
|
||
public void Visit(FeedRangeCompositeContinuation feedRangeCompositeContinuation) | ||
{ | ||
// In case EPK has already been set by compute | ||
if (!this.request.Properties.ContainsKey(HandlerConstants.StartEpkString)) | ||
{ | ||
this.request.Properties[HandlerConstants.StartEpkString] = feedRangeCompositeContinuation.CurrentToken.Range.Min; | ||
this.request.Properties[HandlerConstants.EndEpkString] = feedRangeCompositeContinuation.CurrentToken.Range.Max; | ||
} | ||
|
||
this.fillContinuation(this.request, feedRangeCompositeContinuation.GetContinuation()); | ||
} | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
Microsoft.Azure.Cosmos/src/FeedRange/FeedRanges/FeedRangePartitionKeyRangeExtractor.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,53 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// ------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Documents; | ||
|
||
internal sealed class FeedRangePartitionKeyRangeExtractor : IFeedRangeAsyncVisitor<IReadOnlyList<Documents.Routing.Range<string>>> | ||
{ | ||
private readonly ContainerInternal container; | ||
|
||
public FeedRangePartitionKeyRangeExtractor(ContainerInternal container) | ||
{ | ||
this.container = container ?? throw new ArgumentNullException(nameof(container)); | ||
} | ||
|
||
public async Task<IReadOnlyList<Documents.Routing.Range<string>>> VisitAsync(FeedRangePartitionKey feedRange, CancellationToken cancellationToken = default) | ||
{ | ||
Routing.PartitionKeyRangeCache partitionKeyRangeCache = await this.container.ClientContext.DocumentClient.GetPartitionKeyRangeCacheAsync(); | ||
PartitionKeyDefinition partitionKeyDefinition = await this.container.GetPartitionKeyDefinitionAsync(cancellationToken); | ||
return await feedRange.GetEffectiveRangesAsync( | ||
partitionKeyRangeCache, | ||
await this.container.GetRIDAsync(cancellationToken), | ||
partitionKeyDefinition); | ||
} | ||
|
||
public async Task<IReadOnlyList<Documents.Routing.Range<string>>> VisitAsync(FeedRangePartitionKeyRange feedRange, CancellationToken cancellationToken = default) | ||
{ | ||
// Migration from PKRangeId scenario | ||
Routing.PartitionKeyRangeCache partitionKeyRangeCache = await this.container.ClientContext.DocumentClient.GetPartitionKeyRangeCacheAsync(); | ||
return await feedRange.GetEffectiveRangesAsync( | ||
routingMapProvider: partitionKeyRangeCache, | ||
containerRid: await this.container.GetRIDAsync(cancellationToken), | ||
partitionKeyDefinition: null); | ||
} | ||
|
||
public async Task<IReadOnlyList<Documents.Routing.Range<string>>> VisitAsync(FeedRangeEPK feedRange, CancellationToken cancellationToken = default) | ||
{ | ||
Routing.PartitionKeyRangeCache partitionKeyRangeCache = await this.container.ClientContext.DocumentClient.GetPartitionKeyRangeCacheAsync(); | ||
IReadOnlyList<PartitionKeyRange> pkRanges = await partitionKeyRangeCache.TryGetOverlappingRangesAsync( | ||
collectionRid: await this.container.GetRIDAsync(cancellationToken), | ||
range: feedRange.Range, | ||
forceRefresh: false); | ||
return pkRanges.Select(pkRange => pkRange.ToRange()).ToList(); | ||
} | ||
} | ||
} |
Oops, something went wrong.