public void SaveCheckpoint(long checkpoint) { if (!_started) { _timer.Start(); _started = true; } _bufferCheckpointManager.SaveCheckpoint(checkpoint); }
private Task SendBufferToTarget(CancellationToken token) { var buffer = _bufferCheckpointManager.GetCheckpoint(); if (buffer > _lastSavedCheckpoint) { _targetCheckpointManager.SaveCheckpoint(buffer); _lastSavedCheckpoint = buffer; } return(Task.CompletedTask); }
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); }