Method WatchAsync
- Namespace
- NATS.Client.KeyValueStore
- Assembly
- NATS.Client.KeyValueStore.dll
WatchAsync<T>(string, INatsDeserialize<T>?, NatsKVWatchOpts?, CancellationToken)
Start a watcher for specific keys
public IAsyncEnumerable<NatsKVEntry<T>> WatchAsync<T>(string key, INatsDeserialize<T>? serializer = null, NatsKVWatchOpts? opts = null, CancellationToken cancellationToken = default)
Parameters
keystringKey to watch (subject-based wildcards may be used)
serializerINatsDeserialize<T>Serializer to use for the message type.
optsNatsKVWatchOptsWatch options
cancellationTokenCancellationTokenA CancellationToken used to cancel the API call.
Returns
- IAsyncEnumerable<NatsKVEntry<T>>
An asynchronous enumerable which can be used in
await foreachloops
Type Parameters
TSerialized value type
WatchAsync<T>(IEnumerable<string>, INatsDeserialize<T>?, NatsKVWatchOpts?, CancellationToken)
Start a watcher for specific keys
public IAsyncEnumerable<NatsKVEntry<T>> WatchAsync<T>(IEnumerable<string> keys, INatsDeserialize<T>? serializer = null, NatsKVWatchOpts? opts = null, CancellationToken cancellationToken = default)
Parameters
keysIEnumerable<string>Keys to watch (subject-based wildcards may be used)
serializerINatsDeserialize<T>Serializer to use for the message type.
optsNatsKVWatchOptsWatch options
cancellationTokenCancellationTokenA CancellationToken used to cancel the API call.
Returns
- IAsyncEnumerable<NatsKVEntry<T>>
An asynchronous enumerable which can be used in
await foreachloops
Type Parameters
TSerialized value type
Exceptions
- InvalidOperationException
There was a conflict in options, e.g. IncludeHistory and UpdatesOnly are only valid when ResumeAtRevision is not set.
WatchAsync<T>(INatsDeserialize<T>?, NatsKVWatchOpts?, CancellationToken)
Start a watcher for all the keys in the bucket
public IAsyncEnumerable<NatsKVEntry<T>> WatchAsync<T>(INatsDeserialize<T>? serializer = null, NatsKVWatchOpts? opts = null, CancellationToken cancellationToken = default)
Parameters
serializerINatsDeserialize<T>Serializer to use for the message type.
optsNatsKVWatchOptsWatch options
cancellationTokenCancellationTokenA CancellationToken used to cancel the API call.
Returns
- IAsyncEnumerable<NatsKVEntry<T>>
An asynchronous enumerable which can be used in
await foreachloops
Type Parameters
TSerialized value type