Esempio n. 1
0
        public static async Task BufferizeLogEntries(bool knownLength)
        {
            var content1 = RandomBytes(1024);
            var content2 = RandomBytes(4096);

            await using var entries = new LogEntryProducer <RaftLogEntry>(new RaftLogEntry(42L, content1, knownLength), new RaftLogEntry(43L, content2, knownLength));
            var options = new RaftLogEntriesBufferingOptions {
                MemoryThreshold = 1025
            };

            using var buffered = await BufferedRaftLogEntryList.CopyAsync(entries, options);

            Equal(2L, buffered.Count);
            Equal(content1, await buffered[0].ToByteArrayAsync());
            Equal(content2, await buffered[1].ToByteArrayAsync());
        }
Esempio n. 2
0
 /// <inheritdoc/>
 async ValueTask <long> IAuditTrail <IRaftLogEntry> .AppendAsync <TEntry>(TEntry entry, CancellationToken token)
 {
     using (await syncRoot.AcquireWriteLockAsync(CancellationToken.None).ConfigureAwait(false))
         return(await AppendAsync(LogEntryProducer <TEntry> .Of(entry), null, false, CancellationToken.None).ConfigureAwait(false));
 }