diff --git a/src/Ydb.Sdk/src/Services/Topic/IWriter.cs b/src/Ydb.Sdk/src/Services/Topic/IWriter.cs index 1df99eae..82cddb22 100644 --- a/src/Ydb.Sdk/src/Services/Topic/IWriter.cs +++ b/src/Ydb.Sdk/src/Services/Topic/IWriter.cs @@ -4,7 +4,31 @@ namespace Ydb.Sdk.Services.Topic; public interface IWriter : IDisposable { + /// + /// Asynchronously send a data to a YDB Topic. + /// + /// The data to produce. + /// A cancellation token to observe whilst waiting the returned task to complete. + /// + /// A Task which will complete with a delivery report corresponding to the produce request, + /// or an exception if an error occured. + /// + /// + /// Thrown in response to any write request that was unsuccessful for any reason. + /// public Task WriteAsync(TValue data, CancellationToken cancellationToken = default); + /// + /// Asynchronously send a single message to a YDB Topic. + /// + /// The message to produce + /// A cancellation token to observe whilst waiting the returned task to complete. + /// + /// A Task which will complete with a delivery report corresponding to the produce request, + /// or an exception if an error occured. + /// + /// + /// Thrown in response to any write request that was unsuccessful for any reason. + /// public Task WriteAsync(Message message, CancellationToken cancellationToken = default); } diff --git a/src/Ydb.Sdk/src/Services/Topic/Writer/WriteResult.cs b/src/Ydb.Sdk/src/Services/Topic/Writer/WriteResult.cs index 160d2844..3dd53073 100644 --- a/src/Ydb.Sdk/src/Services/Topic/Writer/WriteResult.cs +++ b/src/Ydb.Sdk/src/Services/Topic/Writer/WriteResult.cs @@ -6,15 +6,12 @@ public class WriteResult { internal static readonly WriteResult Skipped = new(); - private readonly long _offset; - internal WriteResult(StreamWriteMessage.Types.WriteResponse.Types.WriteAck ack) { switch (ack.MessageWriteStatusCase) { case StreamWriteMessage.Types.WriteResponse.Types.WriteAck.MessageWriteStatusOneofCase.Written: Status = PersistenceStatus.Written; - _offset = ack.Written.Offset; break; case StreamWriteMessage.Types.WriteResponse.Types.WriteAck.MessageWriteStatusOneofCase.Skipped: Status = PersistenceStatus.AlreadyWritten; @@ -30,18 +27,24 @@ private WriteResult() Status = PersistenceStatus.AlreadyWritten; } + /// + /// The persistence status of the message + /// public PersistenceStatus Status { get; } - - public bool TryGetOffset(out long offset) - { - offset = _offset; - - return Status == PersistenceStatus.Written; - } } +/// +/// Enumeration of possible message persistence states. +/// public enum PersistenceStatus { + /// + /// The message is recorded + /// Written, + + /// + /// The message was recorded in the last call session + /// AlreadyWritten } diff --git a/src/Ydb.Sdk/src/Services/Topic/Writer/WriterBuilder.cs b/src/Ydb.Sdk/src/Services/Topic/Writer/WriterBuilder.cs index 93b186ee..9a69bb96 100644 --- a/src/Ydb.Sdk/src/Services/Topic/Writer/WriterBuilder.cs +++ b/src/Ydb.Sdk/src/Services/Topic/Writer/WriterBuilder.cs @@ -32,7 +32,7 @@ public WriterBuilder(IDriver driver, string topicPath) /// This limit is applied after the first message has been added to the batch, /// regardless of the first message's size, this is to ensure that messages that exceed buffer size are produced. /// - public int BufferMaxSize { get; set; } = 1024 * 1024; // 1 Mb + public int BufferMaxSize { get; set; } = 20 * 1024 * 1024; // 20 Mb /// /// Explicit partition id to write to.