2using System.Collections.Concurrent;
4using System.Threading.Tasks;
6using HotChocolate.Execution;
7using HotChocolate.Subscriptions;
9using Microsoft.Extensions.Hosting;
48 registrations =
new ConcurrentBag<CancellationTokenRegistration>();
57 registration.Dispose();
65 => WrapWithApplicationLifetimeCancellation(
69 public ValueTask<ISourceStream<TMessage>>
SubscribeAsync<TMessage>(
string topicName,
int? bufferCapacity, TopicBufferFullMode? bufferFullMode, CancellationToken cancellationToken)
70 => WrapWithApplicationLifetimeCancellation(
71 hotChocolateReceiver.SubscribeAsync<TMessage>(topicName, bufferCapacity, bufferFullMode, cancellationToken));
81 var sourceStream = await sourceStreamTask;
85 sourceStream.DisposeAsync().AsTask())));
ValueTask< ISourceStream< TMessage > > SubscribeAsync< TMessage >(string topicName, CancellationToken cancellationToken)
ShutdownAwareTopicEventReceiver(IHostApplicationLifetime hostApplicationLifetime, HotChocolate.Subscriptions.ITopicEventReceiver hotChocolateReceiver)
Initializes a new instance of the ShutdownAwareTopicEventReceiver class.
readonly ConcurrentBag< Task > disposeTasks
A ConcurrentBag<T> of ValueTasks returned from initiating IAsyncDisposable.DisposeAsync calls on ISou...
readonly ConcurrentBag< CancellationTokenRegistration > registrations
A ConcurrentBag<T> of CancellationTokenRegistrations that were created for this scope.
readonly IHostApplicationLifetime hostApplicationLifetime
The IHostApplicationLifetime for the ShutdownAwareTopicEventReceiver.
async ValueTask DisposeAsync()
async ValueTask< ISourceStream< TMessage > > WrapWithApplicationLifetimeCancellation< TMessage >(ValueTask< ISourceStream< TMessage > > sourceStreamTask)
Wraps a given sourceStreamTask with hostApplicationLifetime cancellation awareness.
readonly HotChocolate.Subscriptions.ITopicEventReceiver hotChocolateReceiver
The wrapped HotChocolate.Subscriptions.ITopicEventReceiver.
Implementation of HotChocolate.Subscriptions.ITopicEventReceiver that works around the global::System...