public async Task <AggregateRootCheckpointResult> AppendAsync(AggregateRootCheckpoint <TPayload> checkpoint, CancellationToken token = default)
        {
            _checkpoints.Add(checkpoint);

            var result = AggregateRootCheckpointResult.StorageSucceed(checkpoint.AggregateRootId);

            _logger.LogInformation($"Checkpointed to memory state backend, {checkpoint}.");

            return(await Task.FromResult(result));
        }
        public async Task CheckpointAsync(
            IEventSourcedAggregateRoot aggregateRoot,
            CancellationToken token = default)
        {
            var aggregateRootId     = aggregateRoot.Id;
            var aggregateRootType   = aggregateRoot.GetType().FullName;
            var aggregateGeneration = aggregateRoot.Generation;
            var aggregateVersion    = aggregateRoot.Version;

            var metrics = await _eventStateBackend.StatMetricsAsync(aggregateRootId, aggregateGeneration, token);

            if (metrics.TriggerCheckpoint(_options))
            {
                var nextGeneration = ++aggregateRoot.Generation;
                var checkpoint     = new AggregateRootCheckpoint <IEventSourcedAggregateRoot>(aggregateRoot.Id, aggregateRoot.GetType(), nextGeneration, aggregateRoot.Version, aggregateRoot);

                var message = $"id: {aggregateRootId}, Type: {aggregateRootType}, Generation: {nextGeneration}, Version: {aggregateVersion}, UnCheckpointedBytes: {metrics.UnCheckpointedBytes} >= {_options.UnCheckpointedBytes}, UnCheckpointedCount: {metrics.UnCheckpointedCount} >= {_options.UnCheckpointedCount}";

                try
                {
                    await _checkpointStateBackend.AppendAsync(checkpoint, token);
                }
                catch (Exception e)
                {
                    _logger.LogInformation($"Checkpointing the aggregate root, {message} has a unknown exception: {LogFormatter.PrintException(e)}.");

                    return;
                }

                _logger.LogInformation($"Checkpointed the aggregate root, {message}.");
            }
            else
            {
                _logger.LogInformation($"No triggering checkpoint for the aggregate root, id: {aggregateRootId}, Type: {aggregateRootType}, Generation: {aggregateGeneration}, Version: {aggregateVersion}, UnCheckpointedBytes: {metrics.UnCheckpointedBytes} < {_options.UnCheckpointedBytes}, UnCheckpointedCount: {metrics.UnCheckpointedCount} < {_options.UnCheckpointedCount}.");
            }
        }