private Task DispatchChangesAsync(ResponseMessage response, CancellationToken cancellationToken)
        {
            ChangeFeedObserverContext context = new ChangeFeedObserverContextCore <T>(this.options.LeaseToken, response, this.checkpointer);
            Collection <T>            asFeedResponse;

            try
            {
                asFeedResponse = this.cosmosJsonSerializer.FromStream <CosmosFeedResponseUtil <T> >(response.Content).Data;
            }
            catch (Exception serializationException)
            {
                // Error using custom serializer to parse stream
                throw new ObserverException(serializationException);
            }

            // When StartFromBeginning is used, the first request returns OK but no content
            if (asFeedResponse.Count == 0)
            {
                return(Task.CompletedTask);
            }

            List <T> asReadOnlyList = new List <T>(asFeedResponse.Count);

            asReadOnlyList.AddRange(asFeedResponse);

            return(this.observer.ProcessChangesAsync(context, asReadOnlyList, cancellationToken));
        }
示例#2
0
        private Task DispatchChangesAsync(ResponseMessage response, CancellationToken cancellationToken)
        {
            ChangeFeedObserverContext context = new ChangeFeedObserverContextCore <T>(this.options.LeaseToken, response, this.checkpointer);
            IEnumerable <T>           asFeedResponse;

            try
            {
                asFeedResponse = CosmosFeedResponseSerializer.FromFeedResponseStream <T>(
                    this.serializerCore,
                    response.Content);
            }
            catch (Exception serializationException)
            {
                // Error using custom serializer to parse stream
                throw new ObserverException(serializationException);
            }

            // When StartFromBeginning is used, the first request returns OK but no content
            if (!asFeedResponse.Any())
            {
                return(Task.CompletedTask);
            }

            List <T> asReadOnlyList = new List <T>(asFeedResponse);

            return(this.observer.ProcessChangesAsync(context, asReadOnlyList, cancellationToken));
        }
        private Task DispatchChanges(IFeedResponse <T> response, CancellationToken cancellationToken)
        {
            ChangeFeedObserverContext context = new ChangeFeedObserverContextCore <T>(this.settings.LeaseToken, response, this.checkpointer);
            var docs = new List <T>(response.Count);

            using (IEnumerator <T> e = response.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    docs.Add(e.Current);
                }
            }

            return(this.observer.ProcessChangesAsync(context, docs, cancellationToken));
        }
示例#4
0
        private Task DispatchChangesAsync(CosmosResponseMessage response, CancellationToken cancellationToken)
        {
            ChangeFeedObserverContext context = new ChangeFeedObserverContextCore <T>(this.settings.LeaseToken, response, this.checkpointer);
            Collection <T>            asFeedResponse;

            try
            {
                asFeedResponse = cosmosJsonSerializer.FromStream <CosmosFeedResponseUtil <T> >(response.Content).Data;
            }
            catch (Exception serializationException)
            {
                // Error using custom serializer to parse stream
                throw new ObserverException(serializationException);
            }

            List <T> asReadOnlyList = new List <T>(asFeedResponse.Count);

            asReadOnlyList.AddRange(asFeedResponse);

            return(this.observer.ProcessChangesAsync(context, asReadOnlyList, cancellationToken));
        }
        private Task DispatchChangesAsync(ResponseMessage response, CancellationToken cancellationToken)
        {
            ChangeFeedObserverContextCore context = new ChangeFeedObserverContextCore(this.options.LeaseToken, response, this.checkpointer);

            return(this.observer.ProcessChangesAsync(context, response.Content, cancellationToken));
        }