Skip to content

Commit

Permalink
Callback recieves copy of buffer metadata not buffer itself (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored Apr 9, 2024
1 parent 2cdc188 commit 78cef91
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion examples/playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ async Task DoChannelWrite(int i, CancellationToken cancellationToken)
return;

Console.WriteLine("Failed To write");
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Elastic.Channels/BufferedChannelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ private async Task ExportBufferAsync(ArraySegment<TEvent> items, IOutboundBuffer
try
{
response = await ExportAsync(items, TokenSource.Token).ConfigureAwait(false);
_callbacks.ExportResponseCallback?.Invoke(response, outboundBuffer);
_callbacks.ExportResponseCallback?.Invoke(response,
new WriteTrackingBufferEventData { Count = outboundBuffer.Count, DurationSinceFirstWrite = outboundBuffer.DurationSinceFirstWrite });
}
catch (Exception e)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Elastic.Channels/Buffers/IWriteTrackingBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ public interface IWriteTrackingBuffer
/// </summary>
TimeSpan? DurationSinceFirstWrite { get; }
}

internal class WriteTrackingBufferEventData : IWriteTrackingBuffer
{
public int Count { get; set; }
public TimeSpan? DurationSinceFirstWrite { get; set; }
}

0 comments on commit 78cef91

Please sign in to comment.