public override IAsyncEnumerable <TryCatch <ChangeFeedPage> > GetChangeFeedAsyncEnumerable( ChangeFeedCrossFeedRangeState state, ChangeFeedMode changeFeedMode, ChangeFeedRequestOptions changeFeedRequestOptions = default) { return(base.GetChangeFeedAsyncEnumerable(state, changeFeedMode, changeFeedRequestOptions)); }
public override IAsyncEnumerable <TryCatch <ChangeFeed.ChangeFeedPage> > GetChangeFeedAsyncEnumerable( ChangeFeedCrossFeedRangeState state, ChangeFeedRequestOptions changeFeedRequestOptions = default) { NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, new CosmosDiagnosticsContextCore()); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); return(new ChangeFeedCrossFeedRangeAsyncEnumerable( documentContainer, changeFeedRequestOptions, state)); }
public override IAsyncEnumerable <TryCatch <ChangeFeed.ChangeFeedPage> > GetChangeFeedAsyncEnumerable( ChangeFeedCrossFeedRangeState state, ChangeFeedMode changeFeedMode, ChangeFeedRequestOptions changeFeedRequestOptions = default) { NetworkAttachedDocumentContainer networkAttachedDocumentContainer = new NetworkAttachedDocumentContainer( this, this.queryClient, changeFeedRequestOptions: changeFeedRequestOptions); DocumentContainer documentContainer = new DocumentContainer(networkAttachedDocumentContainer); Dictionary <string, string> additionalHeaders; if ((changeFeedRequestOptions?.Properties != null) && changeFeedRequestOptions.Properties.Any()) { Dictionary <string, object> additionalNonStringHeaders = new Dictionary <string, object>(); additionalHeaders = new Dictionary <string, string>(); foreach (KeyValuePair <string, object> keyValuePair in changeFeedRequestOptions.Properties) { if (keyValuePair.Value is string stringValue) { additionalHeaders[keyValuePair.Key] = stringValue; } else { additionalNonStringHeaders[keyValuePair.Key] = keyValuePair.Value; } } changeFeedRequestOptions.Properties = additionalNonStringHeaders; } else { additionalHeaders = null; } ChangeFeedPaginationOptions changeFeedPaginationOptions = new ChangeFeedPaginationOptions( changeFeedMode, changeFeedRequestOptions?.PageSizeHint, changeFeedRequestOptions?.JsonSerializationFormatOptions?.JsonSerializationFormat, additionalHeaders); return(new ChangeFeedCrossFeedRangeAsyncEnumerable( documentContainer, state, changeFeedPaginationOptions, changeFeedRequestOptions?.JsonSerializationFormatOptions)); }
public async Task ChangeFeedAsync() { int numItems = 100; IDocumentContainer documentContainer = await this.CreateDocumentContainerAsync(numItems); CrossPartitionChangeFeedAsyncEnumerator enumerator = CrossPartitionChangeFeedAsyncEnumerator.Create( documentContainer, ChangeFeedMode.Incremental, new ChangeFeedRequestOptions() { PageSizeHint = int.MaxValue }, new CrossFeedRangeState <ChangeFeedState>( ChangeFeedCrossFeedRangeState.CreateFromBeginning().FeedRangeStates), cancellationToken: default); int numChildren = 0; Trace rootTrace; using (rootTrace = Trace.GetRootTrace("Cross Partition Change Feed")) { while (await enumerator.MoveNextAsync(rootTrace)) { numChildren++; if (enumerator.Current.Result.Page is ChangeFeedNotModifiedPage) { break; } } } string traceString = TraceWriter.TraceToText(rootTrace); Console.WriteLine(traceString); Assert.AreEqual(numChildren, rootTrace.Children.Count); }
public abstract IAsyncEnumerable <TryCatch <ChangeFeedPage> > GetChangeFeedAsyncEnumerable( ChangeFeedCrossFeedRangeState state, ChangeFeedRequestOptions changeFeedRequestOptions = null);
public async Task ScenariosAsync() { List <Input> inputs = new List <Input>(); int startLineNumber; int endLineNumber; //---------------------------------------------------------------- // ReadFeed //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems); CrossPartitionReadFeedAsyncEnumerator enumerator = CrossPartitionReadFeedAsyncEnumerator.Create( documentContainer, new CrossFeedRangeState <ReadFeedState>(ReadFeedCrossFeedRangeState.CreateFromBeginning().FeedRangeStates), new ReadFeedPaginationOptions(pageSizeHint: 10), cancellationToken: default); int numChildren = 1; // One extra since we need to read one past the last user page to get the null continuation. TraceForBaselineTesting rootTrace; using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { while (await enumerator.MoveNextAsync(rootTrace)) { numChildren++; } } Assert.AreEqual(numChildren, rootTrace.Children.Count); endLineNumber = GetLineNumber(); inputs.Add(new Input("ReadFeed", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- //---------------------------------------------------------------- // ChangeFeed //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems); CrossPartitionChangeFeedAsyncEnumerator enumerator = CrossPartitionChangeFeedAsyncEnumerator.Create( documentContainer, new CrossFeedRangeState <ChangeFeedState>( ChangeFeedCrossFeedRangeState.CreateFromBeginning().FeedRangeStates), new ChangeFeedPaginationOptions( ChangeFeedMode.Incremental, pageSizeHint: int.MaxValue), cancellationToken: default); int numChildren = 0; TraceForBaselineTesting rootTrace; using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { while (await enumerator.MoveNextAsync(rootTrace)) { numChildren++; if (enumerator.Current.Result.Page is ChangeFeedNotModifiedPage) { break; } } } Assert.AreEqual(numChildren, rootTrace.Children.Count); endLineNumber = GetLineNumber(); inputs.Add(new Input("ChangeFeed", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- //---------------------------------------------------------------- // Query //---------------------------------------------------------------- { startLineNumber = GetLineNumber(); int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems); IQueryPipelineStage pipelineStage = CreatePipeline(documentContainer, "SELECT * FROM c", pageSize: 10); TraceForBaselineTesting rootTrace; int numChildren = 1; // One extra since we need to read one past the last user page to get the null continuation. using (rootTrace = TraceForBaselineTesting.GetRootTrace()) { while (await pipelineStage.MoveNextAsync(rootTrace)) { numChildren++; } } Assert.AreEqual(numChildren, rootTrace.Children.Count); endLineNumber = GetLineNumber(); inputs.Add(new Input("Query", rootTrace, startLineNumber, endLineNumber)); } //---------------------------------------------------------------- this.ExecuteTestSuite(inputs); }