Ejemplo n.º 1
0
 public void SaveCheckpoint(long checkpoint)
 {
     if (!_started)
     {
         _timer.Start();
         _started = true;
     }
     _bufferCheckpointManager.SaveCheckpoint(checkpoint);
 }
Ejemplo n.º 2
0
        private Task SendBufferToTarget(CancellationToken token)
        {
            var buffer = _bufferCheckpointManager.GetCheckpoint();

            if (buffer > _lastSavedCheckpoint)
            {
                _targetCheckpointManager.SaveCheckpoint(buffer);
                _lastSavedCheckpoint = buffer;
            }
            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        public BufferedCheckpointManager(ICheckpointManager bufferCheckpointManager, ICheckpointManager targetCheckpointManager, int bufferInterval)
        {
            Guard.ArgumentNotNull(bufferCheckpointManager, nameof(bufferCheckpointManager));
            Guard.ArgumentNotNull(targetCheckpointManager, nameof(targetCheckpointManager));

            _bufferCheckpointManager = bufferCheckpointManager;
            _targetCheckpointManager = targetCheckpointManager;
            _bufferInterval          = bufferInterval;

            var bufferCheckpoint = _bufferCheckpointManager.GetCheckpoint();
            var targetCheckpoint = _targetCheckpointManager.GetCheckpoint();

            if (bufferCheckpoint > targetCheckpoint)
            {
                _targetCheckpointManager.SaveCheckpoint(bufferCheckpoint);
            }
            _timer = new PeriodicAction(SendBufferToTarget, bufferInterval);
        }