diff --git a/Microsoft.Azure.Cosmos.Encryption.Custom/src/EncryptionContainer.cs b/Microsoft.Azure.Cosmos.Encryption.Custom/src/EncryptionContainer.cs index eebf5900cf..bdba7677b6 100644 --- a/Microsoft.Azure.Cosmos.Encryption.Custom/src/EncryptionContainer.cs +++ b/Microsoft.Azure.Cosmos.Encryption.Custom/src/EncryptionContainer.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Cosmos.Encryption.Custom using System.Linq; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos; using Newtonsoft.Json.Linq; internal sealed class EncryptionContainer : Container @@ -1023,6 +1022,16 @@ public override Task DeleteAllItemsByPartitionKeyStreamAsync( } #endif +#if SDKPROJECTREF + public override ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( + string processorName, + ChangeFeedHandler> onChangesDelegate) + { + return this.container.GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( + processorName, + onChangesDelegate); + } +#endif private async Task ReadManyItemsHelperAsync( IReadOnlyList<(string id, PartitionKey partitionKey)> items, ReadManyRequestOptions readManyRequestOptions = null, diff --git a/Microsoft.Azure.Cosmos.Encryption/src/EncryptionContainer.cs b/Microsoft.Azure.Cosmos.Encryption/src/EncryptionContainer.cs index 0bd342f0ef..32df3587bb 100644 --- a/Microsoft.Azure.Cosmos.Encryption/src/EncryptionContainer.cs +++ b/Microsoft.Azure.Cosmos.Encryption/src/EncryptionContainer.cs @@ -11,7 +11,6 @@ namespace Microsoft.Azure.Cosmos.Encryption using System.Net; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos; using Newtonsoft.Json.Linq; internal sealed class EncryptionContainer : Container @@ -756,6 +755,14 @@ public override Task> GetPartitionKeyRangesAsync( } #endif +#if SDKPROJECTREF + public override ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( + string processorName, + ChangeFeedHandler> onChangesDelegate) + { + throw new NotImplementedException(); + } +#endif /// /// This function handles the scenario where a container is deleted(say from different Client) and recreated with same Id but with different client encryption policy. /// The idea is to have the container Rid cached and sent out as part of RequestOptions with Container Rid set in "x-ms-cosmos-intended-collection-rid" header. diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs index 5936f5e05d..2ee396cac6 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Cosmos using System.Linq; using System.Threading; using System.Threading.Tasks; - using Microsoft.Azure.Cosmos.Serializer; /// /// Operations for reading, replacing, or deleting a specific, existing container or item in a container by id. @@ -1681,6 +1680,81 @@ public abstract Task DeleteAllItemsByPartitionKeyStreamAsync( public abstract Task> GetPartitionKeyRangesAsync( FeedRange feedRange, CancellationToken cancellationToken = default); + + /// + /// Initializes a for change feed processing with all versions and deletes. + /// + /// Document type + /// A name that identifies the Processor and the particular work it will do. + /// Delegate to receive all changes and deletes + /// + /// + /// > documents, CancellationToken token) => + /// { + /// Console.WriteLine($"number of documents processed: {documents.Count}"); + /// + /// string id = default; + /// string pk = default; + /// string description = default; + /// + /// foreach (ChangeFeedItemChange changeFeedItem in documents) + /// { + /// if (changeFeedItem.Metadata.OperationType != ChangeFeedOperationType.Delete) + /// { + /// id = changeFeedItem.Current.id.ToString(); + /// pk = changeFeedItem.Current.pk.ToString(); + /// description = changeFeedItem.Current.description.ToString(); + /// } + /// else + /// { + /// id = changeFeedItem.Previous.id.ToString(); + /// pk = changeFeedItem.Previous.pk.ToString(); + /// description = changeFeedItem.Previous.description.ToString(); + /// } + /// + /// ChangeFeedOperationType operationType = changeFeedItem.Metadata.OperationType; + /// long previousLsn = changeFeedItem.Metadata.PreviousLsn; + /// DateTime conflictResolutionTimestamp = changeFeedItem.Metadata.ConflictResolutionTimestamp; + /// long lsn = changeFeedItem.Metadata.Lsn; + /// bool isTimeToLiveExpired = changeFeedItem.Metadata.IsTimeToLiveExpired; + /// } + /// + /// return Task.CompletedTask; + /// }) + /// .WithInstanceName(Guid.NewGuid().ToString()) + /// .WithLeaseContainer(leaseContainer) + /// .WithErrorNotification((leaseToken, error) => + /// { + /// Console.WriteLine(error.ToString()); + /// + /// return Task.CompletedTask; + /// }) + /// .Build(); + /// + /// await changeFeedProcessor.StartAsync(); + /// await Task.Delay(1000); + /// await this.Container.CreateItemAsync(new { id = "1", pk = "1", description = "original test" }, partitionKey: new PartitionKey("1")); + /// await this.Container.UpsertItemAsync(new { id = "1", pk = "1", description = "test after replace" }, partitionKey: new PartitionKey("1")); + /// await this.Container.DeleteItemAsync(id: "1", partitionKey: new PartitionKey("1")); + /// + /// allProcessedDocumentsEvent.WaitOne(10 * 1000); + /// + /// await changeFeedProcessor.StopAsync(); + /// ]]> + /// + /// + /// An instance of + public abstract ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( + string processorName, + ChangeFeedHandler> onChangesDelegate); #endif } -} +} \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs index ede4aebc22..f3153a33cf 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInlineCore.cs @@ -14,7 +14,6 @@ namespace Microsoft.Azure.Cosmos using Microsoft.Azure.Cosmos.Query.Core.Monads; using Microsoft.Azure.Cosmos.Query.Core.QueryClient; using Microsoft.Azure.Cosmos.ReadFeed; - using Microsoft.Azure.Cosmos.Serializer; using Microsoft.Azure.Cosmos.Tracing; // This class acts as a wrapper for environments that use SynchronizationContext. @@ -661,14 +660,5 @@ public override Task DeleteAllItemsByPartitionKeyStreamAsync( task: (trace) => base.DeleteAllItemsByPartitionKeyStreamAsync(partitionKey, trace, requestOptions, cancellationToken), openTelemetry: (response) => new OpenTelemetryResponse(response)); } - - public override ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( - string processorName, - ChangeFeedHandler> onChangesDelegate) - { - return base.GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( - processorName, - onChangesDelegate); - } } } \ No newline at end of file diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs index 27b007ed8e..7e980bac56 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs @@ -147,82 +147,11 @@ public abstract Task DeleteAllItemsByPartitionKeyStreamAsync( public abstract Task> GetPartitionKeyRangesAsync( FeedRange feedRange, CancellationToken cancellationToken = default); -#endif - /// - /// Initializes a for change feed processing with all versions and deletes. - /// - /// Document type - /// A name that identifies the Processor and the particular work it will do. - /// Delegate to receive all changes and deletes - /// - /// - /// > documents, CancellationToken token) => - /// { - /// Console.WriteLine($"number of documents processed: {documents.Count}"); - /// - /// string id = default; - /// string pk = default; - /// string description = default; - /// - /// foreach (ChangeFeedItemChange changeFeedItem in documents) - /// { - /// if (changeFeedItem.Metadata.OperationType != ChangeFeedOperationType.Delete) - /// { - /// id = changeFeedItem.Current.id.ToString(); - /// pk = changeFeedItem.Current.pk.ToString(); - /// description = changeFeedItem.Current.description.ToString(); - /// } - /// else - /// { - /// id = changeFeedItem.Previous.id.ToString(); - /// pk = changeFeedItem.Previous.pk.ToString(); - /// description = changeFeedItem.Previous.description.ToString(); - /// } - /// - /// ChangeFeedOperationType operationType = changeFeedItem.Metadata.OperationType; - /// long previousLsn = changeFeedItem.Metadata.PreviousLsn; - /// DateTime conflictResolutionTimestamp = changeFeedItem.Metadata.ConflictResolutionTimestamp; - /// long lsn = changeFeedItem.Metadata.Lsn; - /// bool isTimeToLiveExpired = changeFeedItem.Metadata.IsTimeToLiveExpired; - /// } - /// - /// return Task.CompletedTask; - /// }) - /// .WithInstanceName(Guid.NewGuid().ToString()) - /// .WithLeaseContainer(leaseContainer) - /// .WithErrorNotification((leaseToken, error) => - /// { - /// Console.WriteLine(error.ToString()); - /// - /// return Task.CompletedTask; - /// }) - /// .Build(); - /// - /// await changeFeedProcessor.StartAsync(); - /// await Task.Delay(1000); - /// await this.Container.CreateItemAsync(new { id = "1", pk = "1", description = "original test" }, partitionKey: new PartitionKey("1")); - /// await this.Container.UpsertItemAsync(new { id = "1", pk = "1", description = "test after replace" }, partitionKey: new PartitionKey("1")); - /// await this.Container.DeleteItemAsync(id: "1", partitionKey: new PartitionKey("1")); - /// - /// allProcessedDocumentsEvent.WaitOne(10 * 1000); - /// - /// await changeFeedProcessor.StopAsync(); - /// ]]> - /// - /// - /// An instance of public abstract ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes( string processorName, ChangeFeedHandler> onChangesDelegate); +#endif public abstract class TryExecuteQueryResult { diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json index 66cdf8f4d5..d29800471a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json @@ -299,6 +299,11 @@ "Microsoft.Azure.Cosmos.Container;System.Object;IsAbstract:True;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": { "Subclasses": {}, "Members": { + "Microsoft.Azure.Cosmos.ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes[T](System.String, ChangeFeedHandler`1)": { + "Type": "Method", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedProcessorBuilder GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes[T](System.String, ChangeFeedHandler`1);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:True;IsConstructor:False;IsFinal:False;" + }, "System.Threading.Tasks.Task`1[Microsoft.Azure.Cosmos.ResponseMessage] DeleteAllItemsByPartitionKeyStreamAsync(Microsoft.Azure.Cosmos.PartitionKey, Microsoft.Azure.Cosmos.RequestOptions, System.Threading.CancellationToken)": { "Type": "Method", "Attributes": [],