Пример #1
0
 public async Task RunB(IDistributedSubscriber <string, int> subscriber)
 {
     await subscriber.SubscribeAsync("foo", x =>
     {
         Console.WriteLine(x);
     });
 }
Пример #2
0
        public static ValueTask <IAsyncDisposable> SubscribeAsync <TKey, TMessage>(this IDistributedSubscriber <TKey, TMessage> subscriber, TKey key, Func <TMessage, CancellationToken, ValueTask> handler, Func <TMessage, bool> predicate, AsyncMessageHandlerFilter <TMessage>[] filters, CancellationToken cancellationToken = default)
        {
            var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate);

            filters = (filters.Length == 0)
                ? new[] { predicateFilter }
                : Append(filters, predicateFilter);

            return(subscriber.SubscribeAsync(key, new AnonymousAsyncMessageHandler <TMessage>(handler), filters, cancellationToken));
        }
Пример #3
0
 public static ValueTask <IAsyncDisposable> SubscribeAsync <TKey, TMessage>(this IDistributedSubscriber <TKey, TMessage> subscriber, TKey key, Func <TMessage, CancellationToken, ValueTask> handler, AsyncMessageHandlerFilter <TMessage>[] filters, CancellationToken cancellationToken = default)
 {
     return(subscriber.SubscribeAsync(key, new AnonymousAsyncMessageHandler <TMessage>(handler), filters, cancellationToken));
 }
Пример #4
0
 public static UniTask <IUniTaskAsyncDisposable> SubscribeAsync <TKey, TMessage>(this IDistributedSubscriber <TKey, TMessage> subscriber, TKey key, Action <TMessage> handler, MessageHandlerFilter <TMessage>[] filters, CancellationToken cancellationToken = default)
 {
     return(subscriber.SubscribeAsync(key, new AnonymousMessageHandler <TMessage>(handler), filters, cancellationToken));
 }