当前位置: 首页>>代码示例>>C#>>正文


C# StreamSequenceToken类代码示例

本文整理汇总了C#中StreamSequenceToken的典型用法代码示例。如果您正苦于以下问题:C# StreamSequenceToken类的具体用法?C# StreamSequenceToken怎么用?C# StreamSequenceToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StreamSequenceToken类属于命名空间,在下文中一共展示了StreamSequenceToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeliverBatch

        public async Task<StreamSequenceToken> DeliverBatch(GuidId subscriptionId, Immutable<IBatchContainer> batch, StreamSequenceToken prevToken)
        {
            foreach (var each in batch.Value.GetEvents<object>())
                await handler(each.Item1);

            return null;
        }
开发者ID:NaseUkolyCZ,项目名称:Orleankka,代码行数:7,代码来源:PushExtension.cs

示例2: CompareTo

        public override int CompareTo(StreamSequenceToken other)
        {
            if (other == null)
                return 1;

            var token = other as TimeSequenceToken;
            if (token == null)
                throw new ArgumentOutOfRangeException(nameof(other));

            var difference = Timestamp.CompareTo(token.Timestamp);
            return difference != 0 ? difference : EventIndex.CompareTo(token.EventIndex);
        }
开发者ID:amamh,项目名称:orleans-PipeStreamProvider,代码行数:12,代码来源:TimeSequenceToken.cs

示例3: CompareTo

 public override int CompareTo(StreamSequenceToken other)
 {
     if (other == null)
         return 1;
     
     var token = other as EventSequenceToken;
     if (token == null)
         throw new ArgumentOutOfRangeException("other");
     
     int difference = sequenceNumber.CompareTo(token.sequenceNumber);
     return difference != 0 ? difference : eventIndex.CompareTo(token.eventIndex);
 }
开发者ID:hanin,项目名称:orleans,代码行数:12,代码来源:EventSequenceToken.cs

示例4: GetCacheCursor

 public IQueueCacheCursor GetCacheCursor(Guid streamGuid, string streamNamespace, StreamSequenceToken token)
 {
     // NOTE: We assume the client ALWAYS wants to replay the whole dictionary, if it doesn't then it shouldn't be using this stream type in the first place.
     if (token != null && !(token is DictStreamToken))
     {
         // Null token can come from a stream subscriber that is just interested to start consuming from latest (the most recent event added to the cache).
         throw new ArgumentOutOfRangeException("token", "token must be of type DictStreamToken");
     }
     var dict = GetDict(streamNamespace, streamGuid);
     var dictCursor = dict.GetCursor();
     return new DictQueueCacheCursor(dict, streamNamespace, streamGuid);
 }
开发者ID:amamh,项目名称:orleans-DictStreamProvider,代码行数:12,代码来源:DictQueueCache.cs

示例5: StreamPosition

 public StreamPosition(IStreamIdentity streamIdentity, StreamSequenceToken sequenceToken)
 {
     if (streamIdentity == null)
     {
         throw new ArgumentNullException("streamIdentity");
     }
     if (sequenceToken == null)
     {
         throw new ArgumentNullException("sequenceToken");
     }
     StreamIdentity = streamIdentity;
     SequenceToken = sequenceToken;
 }
开发者ID:Joshua-Ferguson,项目名称:orleans,代码行数:13,代码来源:StreamPosition.cs

示例6: OnNextAsync

        public Task OnNextAsync(int item, StreamSequenceToken token = null)
        {
            logger.Info("OnNextAsync(item={0}, token={1})", item, token != null ? token.ToString() : "null");
            if (failPeriodTimer == null)
            {
                eventsConsumedCount++;
            }
            else if(failPeriodTimer.Elapsed >= failPeriod)
            {
                failPeriodTimer = null;
                eventsConsumedCount++;
            }
            else
            {
                eventsFailedCount++;
                throw new AggregateException("GO WAY!");
            }

            return TaskDone.Done;
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:20,代码来源:FaultableConsumerGrain.cs

示例7: Add

        private void Add(IBatchContainer batch, StreamSequenceToken sequenceToken)
        {
            if (batch == null) throw new ArgumentNullException(nameof(batch));

            var cacheBucket = GetOrCreateBucket();

            cacheBucket.UpdateNumItems(1);
            // Add message to linked list
            var item = new TimedQueueCacheItem
            {
                Batch = batch,
                SequenceToken = sequenceToken,
                CacheBucket = cacheBucket,
            };

            item.Timestamp = GetTimestampForItem(batch);

            var newNode = new LinkedListNode<TimedQueueCacheItem>(item);

            // If it's the first item, then we also update 
            if (cacheBucket.NumCurrentItems == 1)
            {
                Log(_logger, "TimedQueueCache for QueueId:{0}, Add: The oldest timespan in the cache is {1}", Id.ToString(), item.Timestamp);
                cacheBucket.OldestMemberTimestamp = item.Timestamp;
                cacheBucket.OldestMember = newNode;
            }

            // Setting the newest member
            cacheBucket.NewestMemberTimestamp = item.Timestamp;
            cacheBucket.NewestMember = newNode;

            _cachedMessages.AddFirst(newNode);

            _counterMessagesInCache.Increment(Id.ToString(), 1);
        }
开发者ID:gigya,项目名称:Orleans.KafkaStreamProvider,代码行数:35,代码来源:TimedQueueCache.cs

示例8: FindNodeBySequenceToken

        private LinkedListNode<TimedQueueCacheItem> FindNodeBySequenceToken(StreamSequenceToken sequenceToken)
        {
            // First we find a bucket where the node is in
            var sequenceBucket =
                _cacheCursorHistogram.First(
                    bucket =>
                        !sequenceToken.Newer(bucket.NewestMember.Value.SequenceToken) &&
                        !sequenceToken.Older(bucket.OldestMember.Value.SequenceToken));

            // Now that we have the bucket, we iterate on the members there starting from the newest in the bucket
            LinkedListNode<TimedQueueCacheItem> node = sequenceBucket.NewestMember;
            while (node != null && node.Value.SequenceToken.Newer(sequenceToken))
            {
                // did we get to the end?
                // node is the last message in the cache
                if (node.Next == null)
                    break;

                // if sequenceId is between the two, take the lower
                if (node.Next.Value.SequenceToken.Older(sequenceToken))
                {
                    node = node.Next;
                    break;
                }

                node = node.Next;
            }

            return node;
        }
开发者ID:gigya,项目名称:Orleans.KafkaStreamProvider,代码行数:30,代码来源:TimedQueueCache.cs

示例9: GetCacheCursor

        //public virtual IQueueCacheCursor GetCacheCursor(Guid streamGuid, string streamNamespace, StreamSequenceToken token)
        public virtual IQueueCacheCursor GetCacheCursor(IStreamIdentity streamIdentity, StreamSequenceToken token)
        {
            if (token != null && !(token is EventSequenceToken))
            {
                // Null token can come from a stream subscriber that is just interested to
                // start consuming from latest (the most recent event added to the cache).
                throw new ArgumentOutOfRangeException(nameof(token), "token must be of type EventSequenceToken");
            }

            var cursor = new TimedQueueCacheCursor(this, streamIdentity.Guid, streamIdentity.Namespace, _logger);
            InitializeCursor(cursor, token);
            return cursor;
        }
开发者ID:gigya,项目名称:Orleans.KafkaStreamProvider,代码行数:14,代码来源:TimedQueueCache.cs

示例10: ResetCursor

        internal void ResetCursor(SimpleQueueCacheCursor cursor, StreamSequenceToken token)
        {
            Log(logger, "ResetCursor: {0} to token {1}", cursor, token);

            if (cursor.IsSet)
            {
                cursor.Element.Value.CacheBucket.UpdateNumCursors(-1);
            }
            cursor.Reset(token);
        }
开发者ID:PaulNorth,项目名称:orleans,代码行数:10,代码来源:SimpleQueueCache.cs

示例11: OnNextAsync

 private Task OnNextAsync(StreamImmutabilityTestObject myObject, StreamSequenceToken streamSequenceToken)
 {
     _myObject = myObject;
     return TaskDone.Done;
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:5,代码来源:StreamingImmutabilityTestGrain.cs

示例12: AddConsumer

 public StreamConsumerData AddConsumer(GuidId subscriptionId, StreamId streamId, IStreamConsumerExtension streamConsumer, StreamSequenceToken token, IStreamFilterPredicateWrapper filter)
 {
     var consumerData = new StreamConsumerData(subscriptionId, streamId, streamConsumer, filter);
     queueData.Add(subscriptionId, consumerData);
     return consumerData;
 }
开发者ID:stanroze,项目名称:orleans,代码行数:6,代码来源:StreamConsumerCollection.cs

示例13: OnNext

 private Task OnNext(int e, StreamSequenceToken token, int countCapture, Counter count)
 {
     logger.Info("Got next event {0} on handle {1}", e, countCapture);
     var contextValue = RequestContext.Get(SampleStreaming_ProducerGrain.RequestContextKey) as string;
     if (!String.Equals(contextValue, SampleStreaming_ProducerGrain.RequestContextValue))
     {
         throw new Exception(String.Format("Got the wrong RequestContext value {0}.", contextValue));
     }
     count.Increment();
     return TaskDone.Done;
 }
开发者ID:JackWangCUMT,项目名称:orleans,代码行数:11,代码来源:MultipleSubscriptionConsumerGrain.cs

示例14: Equals

 public override bool Equals(StreamSequenceToken other)
 {
     var token = other as EventSequenceToken;
     return token != null && (token.sequenceNumber == sequenceNumber &&
                              token.eventIndex == eventIndex);
 }
开发者ID:hanin,项目名称:orleans,代码行数:6,代码来源:EventSequenceToken.cs

示例15: SetSequenceToken

 /// <summary>
 /// Sets sequence token by serializing it to property.
 /// </summary>
 /// <param name="token"></param>
 public virtual void SetSequenceToken(StreamSequenceToken token)
 {
     SequenceToken = token != null ? GetTokenBytes(token) : null;
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:8,代码来源:StreamDeliveryFailureEntity.cs


注:本文中的StreamSequenceToken类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。