Skip to content

Commit bc0e095

Browse files
documentation & refactoring API (#255)
* Added IWriter & WriteResult documentation. * Increased the default value for BufferMaxSize from 1 to 20. * Removed the TryGetOffset method.
1 parent 5b0a5c5 commit bc0e095

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

src/Ydb.Sdk/src/Services/Topic/IWriter.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,31 @@ namespace Ydb.Sdk.Services.Topic;
44

55
public interface IWriter<TValue> : IDisposable
66
{
7+
/// <summary>
8+
/// Asynchronously send a data to a YDB Topic.
9+
/// </summary>
10+
/// <param name="data">The data to produce.</param>
11+
/// <param name="cancellationToken">A cancellation token to observe whilst waiting the returned task to complete.</param>
12+
/// <returns>
13+
/// A Task which will complete with a delivery report corresponding to the produce request,
14+
/// or an exception if an error occured.
15+
/// </returns>
16+
/// <exception cref="T:Ydb.Sdk.Services.Topic.WriterException">
17+
/// Thrown in response to any write request that was unsuccessful for any reason.
18+
/// </exception>
719
public Task<WriteResult> WriteAsync(TValue data, CancellationToken cancellationToken = default);
820

21+
/// <summary>
22+
/// Asynchronously send a single message to a YDB Topic.
23+
/// </summary>
24+
/// <param name="message">The message to produce</param>
25+
/// <param name="cancellationToken">A cancellation token to observe whilst waiting the returned task to complete.</param>
26+
/// <returns>
27+
/// A Task which will complete with a delivery report corresponding to the produce request,
28+
/// or an exception if an error occured.
29+
/// </returns>
30+
/// <exception cref="T:Ydb.Sdk.Services.Topic.WriterException">
31+
/// Thrown in response to any write request that was unsuccessful for any reason.
32+
/// </exception>
933
public Task<WriteResult> WriteAsync(Message<TValue> message, CancellationToken cancellationToken = default);
1034
}

src/Ydb.Sdk/src/Services/Topic/Writer/WriteResult.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ public class WriteResult
66
{
77
internal static readonly WriteResult Skipped = new();
88

9-
private readonly long _offset;
10-
119
internal WriteResult(StreamWriteMessage.Types.WriteResponse.Types.WriteAck ack)
1210
{
1311
switch (ack.MessageWriteStatusCase)
1412
{
1513
case StreamWriteMessage.Types.WriteResponse.Types.WriteAck.MessageWriteStatusOneofCase.Written:
1614
Status = PersistenceStatus.Written;
17-
_offset = ack.Written.Offset;
1815
break;
1916
case StreamWriteMessage.Types.WriteResponse.Types.WriteAck.MessageWriteStatusOneofCase.Skipped:
2017
Status = PersistenceStatus.AlreadyWritten;
@@ -30,18 +27,24 @@ private WriteResult()
3027
Status = PersistenceStatus.AlreadyWritten;
3128
}
3229

30+
/// <summary>
31+
/// The persistence status of the message
32+
/// </summary>
3333
public PersistenceStatus Status { get; }
34-
35-
public bool TryGetOffset(out long offset)
36-
{
37-
offset = _offset;
38-
39-
return Status == PersistenceStatus.Written;
40-
}
4134
}
4235

36+
/// <summary>
37+
/// Enumeration of possible message persistence states.
38+
/// </summary>
4339
public enum PersistenceStatus
4440
{
41+
/// <summary>
42+
/// The message is recorded
43+
/// </summary>
4544
Written,
45+
46+
/// <summary>
47+
/// The message was recorded in the last call session
48+
/// </summary>
4649
AlreadyWritten
4750
}

src/Ydb.Sdk/src/Services/Topic/Writer/WriterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public WriterBuilder(IDriver driver, string topicPath)
3232
/// This limit is applied after the first message has been added to the batch,
3333
/// regardless of the first message's size, this is to ensure that messages that exceed buffer size are produced.
3434
/// </summary>
35-
public int BufferMaxSize { get; set; } = 1024 * 1024; // 1 Mb
35+
public int BufferMaxSize { get; set; } = 20 * 1024 * 1024; // 20 Mb
3636

3737
/// <summary>
3838
/// Explicit partition id to write to.

0 commit comments

Comments
 (0)