コード例 #1
0
        internal ChangeFeedPartitionKeyResultSetIteratorCore(
            CosmosClientContext clientContext,
            ContainerCore container,
            string partitionKeyRangeId,
            string continuationToken,
            int?maxItemCount,
            ChangeFeedRequestOptions options)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            if (partitionKeyRangeId == null)
            {
                throw new ArgumentNullException(nameof(partitionKeyRangeId));
            }

            this.clientContext       = clientContext;
            this.container           = container;
            this.changeFeedOptions   = options;
            this.MaxItemCount        = maxItemCount;
            this.continuationToken   = continuationToken;
            this.partitionKeyRangeId = partitionKeyRangeId;
        }
コード例 #2
0
        internal void Init(
            CosmosClientOptions clientOptions,
            DocumentClient documentClient)
        {
            this.ClientOptions  = clientOptions;
            this.DocumentClient = documentClient;

            //Request pipeline
            ClientPipelineBuilder clientPipelineBuilder = new ClientPipelineBuilder(
                this,
                this.DocumentClient.ResetSessionTokenRetryPolicy,
                this.ClientOptions.CustomHandlers);

            // DocumentClient is not initialized with any consistency overrides so default is backend consistency
            this.AccountConsistencyLevel = (ConsistencyLevel)this.DocumentClient.ConsistencyLevel;

            this.RequestHandler = clientPipelineBuilder.Build();

            this.ResponseFactory = new CosmosResponseFactory(
                defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
                userJsonSerializer: this.ClientOptions.CosmosSerializerWithWrapperOrDefault);

            this.ClientContext = new ClientContextCore(
                client: this,
                clientOptions: this.ClientOptions,
                userJsonSerializer: this.ClientOptions.CosmosSerializerWithWrapperOrDefault,
                defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
                cosmosResponseFactory: this.ResponseFactory,
                requestHandler: this.RequestHandler,
                documentClient: this.DocumentClient,
                documentQueryClient: new DocumentQueryClient(this.DocumentClient));

            this.offerSet = new Lazy <CosmosOffers>(() => new CosmosOffers(this.DocumentClient), LazyThreadSafetyMode.PublicationOnly);
        }
コード例 #3
0
        internal void Init(
            CosmosClientOptions clientOptions,
            DocumentClient documentClient)
        {
            this.ClientOptions  = clientOptions;
            this.DocumentClient = documentClient;

            //Request pipeline
            ClientPipelineBuilder clientPipelineBuilder = new ClientPipelineBuilder(
                this,
                this.ClientOptions.CustomHandlers);

            this.RequestHandler = clientPipelineBuilder.Build();

            CosmosSerializer userSerializer = this.ClientOptions.GetCosmosSerializerWithWrapperOrDefault();

            this.ResponseFactory = new CosmosResponseFactory(
                defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
                userJsonSerializer: userSerializer);

            CosmosSerializer sqlQuerySpecSerializer = CosmosSqlQuerySpecJsonConverter.CreateSqlQuerySpecSerializer(
                cosmosSerializer: userSerializer,
                propertiesSerializer: this.ClientOptions.PropertiesSerializer);

            this.ClientContext = new ClientContextCore(
                client: this,
                clientOptions: this.ClientOptions,
                userJsonSerializer: userSerializer,
                defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
                sqlQuerySpecSerializer: sqlQuerySpecSerializer,
                cosmosResponseFactory: this.ResponseFactory,
                requestHandler: this.RequestHandler,
                documentClient: this.DocumentClient);
        }
コード例 #4
0
        internal void Init(
            CosmosClientOptions clientOptions,
            DocumentClient documentClient)
        {
            this.ClientOptions  = clientOptions;
            this.DocumentClient = documentClient;

            //Request pipeline
            ClientPipelineBuilder clientPipelineBuilder = new ClientPipelineBuilder(
                this,
                this.ClientOptions.CustomHandlers);

            this.RequestHandler = clientPipelineBuilder.Build();

            this.ResponseFactory = new CosmosResponseFactory(
                defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
                userJsonSerializer: this.ClientOptions.CosmosSerializerWithWrapperOrDefault);

            this.ClientContext = new ClientContextCore(
                client: this,
                clientOptions: this.ClientOptions,
                userJsonSerializer: this.ClientOptions.CosmosSerializerWithWrapperOrDefault,
                defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
                cosmosResponseFactory: this.ResponseFactory,
                requestHandler: this.RequestHandler,
                documentClient: this.DocumentClient,
                documentQueryClient: new DocumentQueryClient(this.DocumentClient));

            this.offerSet = new Lazy <CosmosOffers>(() => new CosmosOffers(this.DocumentClient), LazyThreadSafetyMode.PublicationOnly);
        }
コード例 #5
0
 /// <summary>
 /// Create a <see cref="CosmosTriggers"/>
 /// </summary>
 /// <param name="clientContext">The client context</param>
 /// <param name="container">The <see cref="CosmosContainer"/> the triggers set is related to.</param>
 protected internal CosmosTriggers(
     CosmosClientContext clientContext,
     CosmosContainerCore container)
 {
     this.container     = container;
     this.clientContext = clientContext;
 }
コード例 #6
0
        public BatchAsyncContainerExecutor(
            ContainerCore cosmosContainer,
            CosmosClientContext cosmosClientContext,
            int maxServerRequestOperationCount,
            int maxServerRequestBodyLength,
            int dispatchTimerInSeconds = BatchAsyncContainerExecutor.DefaultDispatchTimerInSeconds)
        {
            if (cosmosContainer == null)
            {
                throw new ArgumentNullException(nameof(cosmosContainer));
            }

            if (maxServerRequestOperationCount < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxServerRequestOperationCount));
            }

            if (maxServerRequestBodyLength < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxServerRequestBodyLength));
            }

            if (dispatchTimerInSeconds < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(dispatchTimerInSeconds));
            }

            this.cosmosContainer                = cosmosContainer;
            this.cosmosClientContext            = cosmosClientContext;
            this.maxServerRequestBodyLength     = maxServerRequestBodyLength;
            this.maxServerRequestOperationCount = maxServerRequestOperationCount;
            this.dispatchTimerInSeconds         = dispatchTimerInSeconds;
            this.timerPool    = new TimerPool(BatchAsyncContainerExecutor.MinimumDispatchTimerInSeconds);
            this.retryOptions = cosmosClientContext.ClientOptions.GetConnectionPolicy().RetryOptions;
        }
コード例 #7
0
        public ChangeFeedIteratorCore(
            ContainerInternal container,
            ChangeFeedRequestOptions changeFeedRequestOptions)
        {
            this.container         = container ?? throw new ArgumentNullException(nameof(container));
            this.clientContext     = container.ClientContext;
            this.changeFeedOptions = changeFeedRequestOptions ?? new ChangeFeedRequestOptions();
            this.lazyContainerRid  = new AsyncLazy <TryCatch <string> >(valueFactory: (innerCancellationToken) =>
            {
                return(this.TryInitializeContainerRIdAsync(innerCancellationToken));
            });
            this.hasMoreResults = true;

            if (this.changeFeedOptions?.From is ChangeFeedRequestOptions.StartFromContinuation startFromContinuation)
            {
                if (!FeedRangeContinuation.TryParse(startFromContinuation.Continuation, out FeedRangeContinuation feedRangeContinuation))
                {
                    throw new ArgumentException(string.Format(ClientResources.FeedToken_UnknownFormat, startFromContinuation.Continuation));
                }

                this.FeedRangeContinuation       = feedRangeContinuation;
                this.changeFeedOptions.FeedRange = feedRangeContinuation.GetFeedRange();
                string continuationToken = feedRangeContinuation.GetContinuation();
                if (continuationToken != null)
                {
                    this.changeFeedOptions.From = ChangeFeedRequestOptions.StartFrom.CreateFromContinuation(continuationToken);
                }
                else
                {
                    this.changeFeedOptions.From = ChangeFeedRequestOptions.StartFrom.CreateFromBeginning();
                }
            }
        }
コード例 #8
0
        public BatchAsyncBatcher(
            int maxBatchOperationCount,
            int maxBatchByteSize,
            CosmosSerializerCore serializerCore,
            BatchAsyncBatcherExecuteDelegate executor,
            BatchAsyncBatcherRetryDelegate retrier,
            CosmosClientContext clientContext)
        {
            if (maxBatchOperationCount < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchOperationCount));
            }

            if (maxBatchByteSize < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchByteSize));
            }

            this.batchOperations        = new List <ItemBatchOperation>(maxBatchOperationCount);
            this.executor               = executor ?? throw new ArgumentNullException(nameof(executor));
            this.retrier                = retrier ?? throw new ArgumentNullException(nameof(retrier));
            this.maxBatchByteSize       = maxBatchByteSize;
            this.maxBatchOperationCount = maxBatchOperationCount;
            this.serializerCore         = serializerCore ?? throw new ArgumentNullException(nameof(serializerCore));
            this.clientContext          = clientContext;
        }
コード例 #9
0
 public static string CreateLinkUri(CosmosClientContext clientContext, DatabaseInternal database, string keyId)
 {
     return(clientContext.CreateLink(
                parentLink: database.LinkUri,
                uriPathSegment: Paths.ClientEncryptionKeysPathSegment,
                id: keyId));
 }
コード例 #10
0
 internal CosmosStoredProceduresCore(
     CosmosClientContext clientContext,
     CosmosContainerCore container)
 {
     this.container     = container;
     this.clientContext = clientContext;
 }
コード例 #11
0
 internal FeedIteratorInlineCore(
     FeedIteratorInternal feedIteratorInternal,
     CosmosClientContext clientContext)
 {
     this.feedIteratorInternal = feedIteratorInternal ?? throw new ArgumentNullException(nameof(feedIteratorInternal));
     this.clientContext        = clientContext;
 }
コード例 #12
0
 /// <summary>
 /// Create a <see cref="CosmosUserDefinedFunctions"/>
 /// </summary>
 /// <param name="clientContext">The client context.</param>
 /// <param name="container">The <see cref="CosmosContainer"/> the user defined function set is related to.</param>
 protected internal CosmosUserDefinedFunctions(
     CosmosClientContext clientContext,
     CosmosContainerCore container)
 {
     this.container     = container;
     this.clientContext = clientContext;
 }
コード例 #13
0
        public BatchAsyncContainerExecutor(
            ContainerInternal cosmosContainer,
            CosmosClientContext cosmosClientContext,
            int maxServerRequestOperationCount,
            int maxServerRequestBodyLength)
        {
            if (cosmosContainer == null)
            {
                throw new ArgumentNullException(nameof(cosmosContainer));
            }

            if (maxServerRequestOperationCount < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxServerRequestOperationCount));
            }

            if (maxServerRequestBodyLength < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(maxServerRequestBodyLength));
            }

            this.cosmosContainer                = cosmosContainer;
            this.cosmosClientContext            = cosmosClientContext;
            this.maxServerRequestBodyLength     = maxServerRequestBodyLength;
            this.maxServerRequestOperationCount = maxServerRequestOperationCount;
            this.timerWheel   = TimerWheel.CreateTimerWheel(BatchAsyncContainerExecutor.TimerWheelResolution, BatchAsyncContainerExecutor.TimerWheelBucketCount);
            this.retryOptions = cosmosClientContext.ClientOptions.GetConnectionPolicy().RetryOptions;
        }
コード例 #14
0
 internal static Uri CreateLinkUri(CosmosClientContext clientContext, DatabaseCore database, string keyId)
 {
     return(clientContext.CreateLink(
                parentLink: database.LinkUri.OriginalString,
                uriPathSegment: Paths.ClientEncryptionKeysPathSegment,
                id: keyId));
 }
コード例 #15
0
        public BatchAsyncContainerExecutor GetExecutorForContainer(
            ContainerInternal container,
            CosmosClientContext cosmosClientContext)
        {
            if (!cosmosClientContext.ClientOptions.AllowBulkExecution)
            {
                throw new InvalidOperationException("AllowBulkExecution is not currently enabled.");
            }

            string containerLink = container.LinkUri.ToString();

            if (this.executorsPerContainer.TryGetValue(containerLink, out BatchAsyncContainerExecutor executor))
            {
                return(executor);
            }

            BatchAsyncContainerExecutor newExecutor = new BatchAsyncContainerExecutor(
                container,
                cosmosClientContext,
                Constants.MaxOperationsInDirectModeBatchRequest,
                Constants.MaxDirectModeBatchRequestBodySizeInBytes);

            if (!this.executorsPerContainer.TryAdd(containerLink, newExecutor))
            {
                newExecutor.Dispose();
            }

            return(this.executorsPerContainer[containerLink]);
        }
コード例 #16
0
 internal ConflictsInlineCore(
     CosmosClientContext clientContext,
     ContainerInternal container)
     : base(
         clientContext,
         container)
 {
 }
コード例 #17
0
 public ReadManyQueryHelper(PartitionKeyDefinition partitionKeyDefinition,
                            ContainerCore container)
 {
     this.partitionKeyDefinition = partitionKeyDefinition;
     this.partitionKeySelectors  = this.CreatePkSelectors(partitionKeyDefinition);
     this.container     = container;
     this.clientContext = container.ClientContext;
 }
コード例 #18
0
 internal CosmosContainersCore(
     CosmosClientContext clientContext,
     CosmosDatabaseCore database)
 {
     this.database       = database;
     this.clientContext  = clientContext;
     this.containerCache = new ConcurrentDictionary <string, CosmosContainer>();
 }
コード例 #19
0
 internal CosmosQueryClientCore(
     CosmosClientContext clientContext,
     ContainerCore cosmosContainerCore)
 {
     this.clientContext       = clientContext ?? throw new ArgumentException(nameof(clientContext));
     this.cosmosContainerCore = cosmosContainerCore ?? throw new ArgumentException(nameof(cosmosContainerCore));
     this.DocumentQueryClient = clientContext.DocumentQueryClient ?? throw new ArgumentException(nameof(clientContext));
 }
コード例 #20
0
 internal DatabaseInlineCore(
     CosmosClientContext clientContext,
     string databaseId)
     : base(
         clientContext,
         databaseId)
 {
 }
コード例 #21
0
 public CosmosQueryClientCore(
     CosmosClientContext clientContext,
     ContainerInternal cosmosContainerCore)
 {
     this.clientContext       = clientContext ?? throw new ArgumentException(nameof(clientContext));
     this.cosmosContainerCore = cosmosContainerCore;
     this.documentClient      = this.clientContext.DocumentClient;
     this.semaphore           = new SemaphoreSlim(1, 1);
 }
コード例 #22
0
 public ChangeFeedPartitionKeyResultSetIteratorCore(
     CosmosClientContext clientContext,
     ContainerInternal container,
     ChangeFeedRequestOptions options)
 {
     this.clientContext     = clientContext ?? throw new ArgumentNullException(nameof(clientContext));
     this.container         = container ?? throw new ArgumentNullException(nameof(container));
     this.changeFeedOptions = options;
 }
コード例 #23
0
 internal CosmosItemsCore(
     CosmosClientContext clientContext,
     CosmosContainerCore container,
     CosmosQueryClient queryClient = null)
 {
     this.clientContext             = clientContext;
     this.container                 = container;
     this.cachedUriSegmentWithoutId = this.GetResourceSegmentUriWithoutId();
     this.queryClient               = queryClient ?? new CosmosQueryClientCore(this.clientContext, container);
 }
コード例 #24
0
 internal ClientEncryptionKeyInlineCore(
     CosmosClientContext clientContext,
     DatabaseInternal database,
     string keyId)
     : base(
         clientContext,
         database,
         keyId)
 {
 }
コード例 #25
0
 internal PermissionInlineCore(
     CosmosClientContext clientContext,
     UserCore user,
     string userId)
     : base(
         clientContext,
         user,
         userId)
 {
 }
コード例 #26
0
 internal UserInlineCore(
     CosmosClientContext clientContext,
     DatabaseInternal database,
     string userId)
     : base(
         clientContext,
         database,
         userId)
 {
 }
コード例 #27
0
 internal DatabaseCore(
     CosmosClientContext clientContext,
     string databaseId)
 {
     this.Id            = databaseId;
     this.ClientContext = clientContext;
     this.LinkUri       = clientContext.CreateLink(
         parentLink: null,
         uriPathSegment: Paths.DatabasesPathSegment,
         id: databaseId);
 }
コード例 #28
0
        internal DataEncryptionKeyCore(
            CosmosClientContext clientContext,
            DatabaseCore database,
            string keyId)
        {
            this.Id            = keyId;
            this.ClientContext = clientContext;
            this.LinkUri       = DataEncryptionKeyCore.CreateLinkUri(clientContext, database, keyId);

            this.Database = database;
        }
コード例 #29
0
 internal ContainerInlineCore(
     CosmosClientContext clientContext,
     DatabaseInternal database,
     string containerId,
     CosmosQueryClient cosmosQueryClient = null)
     : base(clientContext,
            database,
            containerId,
            cosmosQueryClient)
 {
 }
コード例 #30
0
        internal FeedIteratorInlineCore(
            FeedIterator feedIterator,
            CosmosClientContext clientContext)
        {
            if (!(feedIterator is FeedIteratorInternal feedIteratorInternal))
            {
                throw new ArgumentNullException(nameof(feedIterator));
            }

            this.feedIteratorInternal = feedIteratorInternal;
            this.clientContext        = clientContext;
        }