diff --git a/examples/playground/Program.cs b/examples/playground/Program.cs index 62a6824..bf28e12 100644 --- a/examples/playground/Program.cs +++ b/examples/playground/Program.cs @@ -61,7 +61,6 @@ async Task DoChannelWrite(int i, CancellationToken cancellationToken) return; Console.WriteLine("Failed To write"); - await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); } } diff --git a/src/Elastic.Channels/BufferedChannelBase.cs b/src/Elastic.Channels/BufferedChannelBase.cs index b20a941..54db5d5 100644 --- a/src/Elastic.Channels/BufferedChannelBase.cs +++ b/src/Elastic.Channels/BufferedChannelBase.cs @@ -277,7 +277,8 @@ private async Task ExportBufferAsync(ArraySegment 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) { diff --git a/src/Elastic.Channels/Buffers/IWriteTrackingBuffer.cs b/src/Elastic.Channels/Buffers/IWriteTrackingBuffer.cs index 4b3d78a..dca6516 100644 --- a/src/Elastic.Channels/Buffers/IWriteTrackingBuffer.cs +++ b/src/Elastic.Channels/Buffers/IWriteTrackingBuffer.cs @@ -19,3 +19,9 @@ public interface IWriteTrackingBuffer /// TimeSpan? DurationSinceFirstWrite { get; } } + +internal class WriteTrackingBufferEventData : IWriteTrackingBuffer +{ + public int Count { get; set; } + public TimeSpan? DurationSinceFirstWrite { get; set; } +}