Example #1
0
        public static ISourceBlock <Either <TLeft, IList <TSuccess> > > BufferSafe <TLeft, TSuccess>(this ISourceBlock <Either <TLeft, TSuccess> > source,
                                                                                                     TimeSpan batchTimeout, int batchMaxSize)
        {
            var outputBlock = new BufferBlock <Either <TLeft, IList <TSuccess> > >();

            source.AsObservable()
            .BufferSafe(batchTimeout, batchMaxSize)
            .Subscribe(outputBlock.AsObserver());

            return(outputBlock);
        }
Example #2
0
        public static ISourceBlock <IList <T> > Buffer <T>(this ISourceBlock <T> source,
                                                           TimeSpan batchTimeout, int batchMaxSize)
        {
            var outputBlock = new BufferBlock <IList <T> >();

            source.AsObservable()
            .Buffer(batchTimeout, batchMaxSize)
            .Where(buffer => buffer.Count > 0)
            .Subscribe(outputBlock.AsObserver());

            return(outputBlock);
        }
Example #3
0
 public static IDisposable LinkTo <TOutput, TState>(
     this ISourceBlock <TOutput> source,
     IAgent <TOutput, TState> agent)
 => source.AsObservable().Subscribe(agent.Post);
Example #4
0
 public static IEnumerable <T> ToEnumerable <T>(this ISourceBlock <T> source, CancellationToken cancelToken = default(CancellationToken))
 {
     return(source.AsObservable().ToEnumerable());
 }