Beispiel #1
0
            private protected async ValueTask ConsumeAsync()
            {
                await reader.ReadBlockAsync(metadataBuffer.AsMemory()).ConfigureAwait(false);

                metadata = new LogEntryMetadata(metadataBuffer);
                consumed = false;
            }
Beispiel #2
0
            // fast path - attempt to consume metadata synchronously
            private bool TryConsume()
            {
                if (!reader.TryReadBlock(LogEntryMetadata.Size, out var result) || result.IsCanceled)
                {
                    return(false);
                }

                metadata = new(result.Buffer, out var metadataEnd);
                reader.AdvanceTo(metadataEnd);
                consumed = false;
                return(true);
            }
Beispiel #3
0
            // slow path - consume metadata asynchronously and allocate buffer on the heap
            private async ValueTask ConsumeSlowAsync()
            {
                if (metadataBuffer.IsEmpty)
                {
                    metadataBuffer = new(new byte[LogEntryMetadata.Size]);
                }

                await reader.ReadBlockAsync(metadataBuffer).ConfigureAwait(false);

                metadata = new(metadataBuffer);
                consumed = false;
            }
 internal static SnapshotMetadata Create <TLogEntry>(TLogEntry snapshot, long index, long length)
     where TLogEntry : IRaftLogEntry
 => new SnapshotMetadata(LogEntryMetadata.Create(snapshot, Size, length), index);
 private SnapshotMetadata(LogEntryMetadata metadata, long index)
 {
     Index          = index;
     RecordMetadata = metadata;
 }