Skip to content

Commit

Permalink
complete request stream on rusi sub dispose (#234)
Browse files Browse the repository at this point in the history
Co-authored-by: Radu Popovici <rpopovici@totalsoft.ro>
  • Loading branch information
oncicaradupopovici and Radu Popovici authored Jul 26, 2022
1 parent e34d5ee commit 7dea3bb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Messaging/NBB.Messaging.Rusi/RusiMessagingTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,20 @@ public async Task<IDisposable> SubscribeAsync(string topic, Func<TransportReceiv
}
}, cancellationToken);

return Task.FromResult<IDisposable>(subscription);
return Task.FromResult<IDisposable>(new RusiSubscription(subscription));
}
}

internal class RusiSubscription : IDisposable
{
private readonly AsyncDuplexStreamingCall<SubscribeRequest, ReceivedMessage> _call;

public RusiSubscription(AsyncDuplexStreamingCall<SubscribeRequest, ReceivedMessage> call) => _call = call;

public void Dispose()
{
_call.RequestStream.CompleteAsync().GetAwaiter().GetResult(); //block since the api does not support IAsyncDisposable
_call.Dispose();
}
}
}

0 comments on commit 7dea3bb

Please sign in to comment.