コード例 #1
0
            public override TryCatch <CrossPartitionState <ChangeFeedState> > Visit(ChangeFeedStartFromContinuation startFromContinuation)
            {
                string continuationToken = startFromContinuation.Continuation;
                TryCatch <CosmosArray> monadicCosmosArray = CosmosArray.Monadic.Parse(continuationToken);

                if (monadicCosmosArray.Failed)
                {
                    return(TryCatch <CrossPartitionState <ChangeFeedState> > .FromException(
                               new MalformedChangeFeedContinuationTokenException(
                                   message : $"Array expected for change feed continuation token: {continuationToken}.",
                                   innerException : monadicCosmosArray.Exception)));
                }

                CosmosArray cosmosArray = monadicCosmosArray.Result;

                if (cosmosArray.Count == 0)
                {
                    return(TryCatch <CrossPartitionState <ChangeFeedState> > .FromException(
                               new MalformedChangeFeedContinuationTokenException(
                                   message : $"non empty array expected for change feed continuation token: {continuationToken}.")));
                }

                List <(FeedRangeInternal, ChangeFeedState)> rangeAndStates = new List <(FeedRangeInternal, ChangeFeedState)>();

                foreach (CosmosElement arrayItem in cosmosArray)
                {
                    TryCatch <ChangeFeedContinuationToken> monadicChangeFeedContinuationToken = ChangeFeedContinuationToken.MonadicConvertFromCosmosElement(arrayItem);
                    if (monadicChangeFeedContinuationToken.Failed)
                    {
                        return(TryCatch <CrossPartitionState <ChangeFeedState> > .FromException(
                                   new MalformedChangeFeedContinuationTokenException(
                                       message : $"Failed to parse change feed continuation token: {continuationToken}.",
                                       innerException : monadicChangeFeedContinuationToken.Exception)));
                    }

                    ChangeFeedContinuationToken changeFeedContinuationToken = monadicChangeFeedContinuationToken.Result;
                    rangeAndStates.Add((changeFeedContinuationToken.Range, changeFeedContinuationToken.State));
                }

                CrossPartitionState <ChangeFeedState> crossPartitionState = new CrossPartitionState <ChangeFeedState>(rangeAndStates);

                return(TryCatch <CrossPartitionState <ChangeFeedState> > .FromResult(crossPartitionState));
            }
コード例 #2
0
 public abstract TResult Visit(ChangeFeedStartFromContinuation startFromContinuation);
コード例 #3
0
 public abstract void Visit(ChangeFeedStartFromContinuation startFromContinuation);