• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# StreamSequenceToken类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetTokenBytes

 private static byte[] GetTokenBytes(StreamSequenceToken token)
 {
     var bodyStream = new BinaryTokenStreamWriter();
     SerializationManager.Serialize(token, bodyStream);
     return bodyStream.ToByteArray();
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:6,代码来源:StreamDeliveryFailureEntity.cs


示例17: Reset

 internal void Reset(StreamSequenceToken token)
 {
     Element = null;
     SequenceToken = token;
 }
开发者ID:osjimenez,项目名称:orleans,代码行数:5,代码来源:SimpleQueueCacheCursor.cs


示例18: GetCacheCursor

        public virtual IQueueCacheCursor GetCacheCursor(Guid streamGuid, string streamNamespace, 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("token", "token must be of type EventSequenceToken");
            }

            var cursor = new SimpleQueueCacheCursor(this, streamGuid, streamNamespace, logger);
            InitializeCursor(cursor, token, true);
            return cursor;
        }
开发者ID:randa1,项目名称:orleans,代码行数:12,代码来源:SimpleQueueCache.cs


示例19: InitializeCursor

        internal void InitializeCursor(SimpleQueueCacheCursor cursor, StreamSequenceToken sequenceToken, bool enforceSequenceToken)
        {
            Log(logger, "InitializeCursor: {0} to sequenceToken {1}", cursor, sequenceToken);
           
            if (cachedMessages.Count == 0) // nothing in cache
            {
                StreamSequenceToken tokenToReset = sequenceToken ?? (lastSequenceTokenAddedToCache != null ? ((EventSequenceToken)lastSequenceTokenAddedToCache).NextSequenceNumber() : null);
                ResetCursor(cursor, tokenToReset);
                return;
            }

            // if offset is not set, iterate from newest (first) message in cache, but not including the irst message itself
            if (sequenceToken == null)
            {
                StreamSequenceToken tokenToReset = lastSequenceTokenAddedToCache != null ? ((EventSequenceToken)lastSequenceTokenAddedToCache).NextSequenceNumber() : null;
                ResetCursor(cursor, tokenToReset);
                return;
            }

            if (sequenceToken.Newer(cachedMessages.First.Value.SequenceToken)) // sequenceId is too new to be in cache
            {
                ResetCursor(cursor, sequenceToken);
                return;
            }

            LinkedListNode<SimpleQueueCacheItem> lastMessage = cachedMessages.Last;
            // Check to see if offset is too old to be in cache
            if (sequenceToken.Older(lastMessage.Value.SequenceToken))
            {
                if (enforceSequenceToken)
                {
                    // throw cache miss exception
                    throw new QueueCacheMissException(sequenceToken, cachedMessages.Last.Value.SequenceToken, cachedMessages.First.Value.SequenceToken);
                }
                sequenceToken = lastMessage.Value.SequenceToken;
            }

            // Now the requested sequenceToken is set and is also within the limits of the cache.

            // Find first message at or below offset
            // Events are ordered from newest to oldest, so iterate from start of list until we hit a node at a previous offset, or the end.
            LinkedListNode<SimpleQueueCacheItem> node = cachedMessages.First;
            while (node != null && node.Value.SequenceToken.Newer(sequenceToken))
            {
                // did we get to the end?
                if (node.Next == null) // node is the last message
                    break;
                
                // if sequenceId is between the two, take the higher
                if (node.Next.Value.SequenceToken.Older(sequenceToken))
                    break;
                
                node = node.Next;
            }

            // return cursor from start.
            SetCursor(cursor, node);
        }
开发者ID:PaulNorth,项目名称:orleans,代码行数:58,代码来源:SimpleQueueCache.cs


示例20: AddSubscriber_Impl

        // Called by rendezvous when new remote subscriber subscribes to this stream.
        private async Task AddSubscriber_Impl(
            GuidId subscriptionId,
            StreamId streamId,
            IStreamConsumerExtension streamConsumer,
            StreamSequenceToken cacheToken,
            IStreamFilterPredicateWrapper filter)
        {
            if (IsShutdown) return;

            StreamConsumerCollection streamDataCollection;
            if (!pubSubCache.TryGetValue(streamId, out streamDataCollection))
            {
                streamDataCollection = new StreamConsumerCollection(DateTime.UtcNow);
                pubSubCache.Add(streamId, streamDataCollection);
            }

            StreamConsumerData data;
            if (!streamDataCollection.TryGetConsumer(subscriptionId, out data))
                data = streamDataCollection.AddConsumer(subscriptionId, streamId, streamConsumer, filter ?? DefaultStreamFilter);

            if (await DoHandshakeWithConsumer(data, cacheToken))
            {
                if (data.State == StreamConsumerDataState.Inactive)
                    RunConsumerCursor(data, data.Filter).Ignore(); // Start delivering events if not actively doing so
            }
        }
开发者ID:NingnaD,项目名称:orleans,代码行数:27,代码来源:PersistentStreamPullingAgent.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StreamState类代码示例发布时间:2022-05-24
下一篇:
C# StreamReader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap