Class Subscription
A live pub/sub subscription from SubscribeAsync(IEnumerable<string>, CancellationToken): enumerate it
once with await foreach for the events, in arrival order; dispose it to end the
subscription. A stream failure or cancellation is thrown from the enumeration.
public sealed class Subscription : IAsyncEnumerable<SubscribeResponse>, IAsyncDisposable
- Inheritance
-
Subscription
- Implements
-
IAsyncEnumerable<SubscribeResponse>
- Inherited Members
Constructors
Subscription(IAsyncEnumerable<SubscribeResponse>, Func<ValueTask>)
A subscription over events, ended by dispose:
for hosts other than the gateway (an in-process bus) that hand out the same type.
public Subscription(IAsyncEnumerable<SubscribeResponse> events, Func<ValueTask> dispose)
Parameters
eventsIAsyncEnumerable<SubscribeResponse>disposeFunc<ValueTask>
Methods
DisposeAsync()
Ends the subscription (cancels the stream). Idempotent.
public ValueTask DisposeAsync()
Returns
GetAsyncEnumerator(CancellationToken)
Returns an enumerator that iterates asynchronously through the collection.
public IAsyncEnumerator<SubscribeResponse> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA CancellationToken that may be used to cancel the asynchronous iteration.
Returns
- IAsyncEnumerator<SubscribeResponse>
An enumerator that can be used to iterate asynchronously through the collection.