private BufferredQueue(BufferredQueueOptions options) { _interval = options.BufferSize * 1000; _batchBlock = new BatchBlock <TData>(options.BufferSize, options.GroupingDataflowBlockOptions ?? new GroupingDataflowBlockOptions { Greedy = true }); _timer = new Timer(_ => { _batchBlock.TriggerBatch(); }, null, _interval, _interval); Func <TData, TData> resetTimerIdentity = value => { _timer.Change(_interval, Timeout.Infinite); return(value); }; var messageAction = new ActionBlock <IEnumerable <TData> >(async(messages) => await TryReceiveThrottledMessage(messages)); _timingBlock = new TransformBlock <TData, TData>(resetTimerIdentity); //the order is important. _timingBlock.LinkTo(_batchBlock); _batchBlock.LinkTo(messageAction); }
public BufferredQueue(BufferredQueueOptions options, IBufferedTarget <TData> bufferedTarget) : this(options) { _bufferedTarget = bufferedTarget; }
public BufferredQueue(BufferredQueueOptions options, Func <IEnumerable <TData>, Task> continuation) : this(options) { _continuation = continuation; }