private void InitializeDataflow(CancellationToken cancellationToken = default)
        {
            var writeBlockSettings = new ExecutionDataflowBlockOptions()
            {
                CancellationToken = cancellationToken,
                BoundedCapacity   = 2
            };

            var batchBlockSettings = new GroupingDataflowBlockOptions()
            {
                CancellationToken = cancellationToken,
                BoundedCapacity   = _portion * 2
            };

            _writeBlock = new ActionBlock <T[]>(c => _storage.WriteEventLogDataAsync(c.ToList(), cancellationToken), writeBlockSettings);
            _batchBlock = new BatchBlock <T>(_portion, batchBlockSettings);

            _batchBlock.LinkTo(_writeBlock, new DataflowLinkOptions()
            {
                PropagateCompletion = true
            });
        }
Ejemplo n.º 2
0
        private void InitializeDataflow(CancellationToken cancellationToken = default)
        {
            var writeBlockSettings = new ExecutionDataflowBlockOptions()
            {
                CancellationToken      = cancellationToken,
                BoundedCapacity        = _collectedFactor,
                MaxDegreeOfParallelism = _writingMaxDop
            };

            var batchBlockSettings = new GroupingDataflowBlockOptions()
            {
                CancellationToken = cancellationToken,
                BoundedCapacity   = _portion * _collectedFactor
            };

            _writeBlock = new ActionBlock <EventLogItem[]>(c => _storage.WriteEventLogDataAsync(c.ToList(), cancellationToken), writeBlockSettings);
            _batchBlock = new BatchBlock <EventLogItem>(_portion, batchBlockSettings);

            _batchBlock.LinkTo(_writeBlock, new DataflowLinkOptions()
            {
                PropagateCompletion = true
            });
        }