public async Task Deliver(DeliveryContext <GrpcTransportMessage> context, string routingKey) { if (_children.TryGetValue("#", out var hashNode)) { await hashNode.Deliver(context, default).ConfigureAwait(false); } if (string.IsNullOrWhiteSpace(routingKey)) { await _sinks.ForEachAsync(async sink => { if (context.WasAlreadyDelivered(sink)) { return; } await sink.Deliver(context).ConfigureAwait(false); context.Delivered(sink); }).ConfigureAwait(false); } else { var separator = routingKey.IndexOf('.'); if (separator < 0) { if (_children.TryGetValue("*", out var starNode)) { await starNode.Deliver(context, default).ConfigureAwait(false); } if (_children.TryGetValue(routingKey, out var childNode)) { await childNode.Deliver(context, default).ConfigureAwait(false); } } else { var word = routingKey.Substring(0, separator); var remaining = routingKey.Substring(separator + 1); if (_children.TryGetValue("*", out var starNode)) { await starNode.Deliver(context, remaining).ConfigureAwait(false); } if (_children.TryGetValue(word, out var childNode)) { await childNode.Deliver(context, remaining).ConfigureAwait(false); } } } }
async Task DispatchMessage(InMemoryTransportMessage message) { await _consumer.Task.ConfigureAwait(false); try { await _consumers.ForEachAsync(x => x.Consume(message, CancellationToken.None)).ConfigureAwait(false); } // ReSharper disable once EmptyGeneralCatchClause catch { } }
public async Task Deliver(DeliveryContext <GrpcTransportMessage> context) { await _sinks.ForEachAsync(async sink => { if (context.WasAlreadyDelivered(sink)) { return; } await sink.Deliver(context).ConfigureAwait(false); context.Delivered(sink); }).ConfigureAwait(false); }
public Task Send(TContext context, IPipe <TContext> next) { var connectionsTask = _connections.ForEachAsync(pipe => pipe.Send(context)); if (connectionsTask.IsCompletedSuccessfully()) { return(next.Send(context)); } async Task SendAsync() { await connectionsTask.ConfigureAwait(false); await next.Send(context).ConfigureAwait(false); } return(SendAsync()); }
async Task DispatchMessage(InMemoryTransportMessage message) { var consumer = await _consumer.Task.ConfigureAwait(false); if (_cancellationToken.IsCancellationRequested) { return; } try { await _consumers.ForEachAsync(x => x.Consume(message, _cancellationToken.Token)).ConfigureAwait(false); } catch { } finally { Interlocked.Decrement(ref _queueDepth); } }
public async Task Send(ConsumeContext <T> context, IPipe <ConsumeContext <T> > next) { await _connections.ForEachAsync(async pipe => await pipe.Send(context).ConfigureAwait(false)).ConfigureAwait(false); await next.Send(context).ConfigureAwait(false); }
Task IReceiveEndpointObserver.Ready(ReceiveEndpointReady ready) { return(_handles.ForEachAsync(x => x.SetReady(ready))); }
public async Task Send(TContext context, IPipe <TContext> next) { await _connections.ForEachAsync(pipe => pipe.Send(context)).ConfigureAwait(false); await next.Send(context).ConfigureAwait(false); }