本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例11: OnNextAsync
private Task OnNextAsync(StreamImmutabilityTestObject myObject, StreamSequenceToken streamSequenceToken)
{
_myObject = myObject;
return TaskDone.Done;
}
示例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;
}
示例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;
}
示例14: Equals
public override bool Equals(StreamSequenceToken other)
{
var token = other as EventSequenceToken;
return token != null && (token.sequenceNumber == sequenceNumber &&
token.eventIndex == eventIndex);
}
示例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;
}