public async Task WriteAsync(NetStreamResult result) { await this.WriteAsync(new NetStreamResult <TResponse>(result.Message, result.Headers)); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null) { if (Next == null) { return(new NetStreamResult(null)); } if (_filter(consumeContext)) { return(await Next.Execute(consumeContext, token, new NetStreamResult(consumeContext.Message))); } return(new NetStreamResult(null)); }
public async Task WriteAsync(NetStreamResult <TResponse> result) { await _producer.ProduceAsync(_resolveKey(result.Message), result.Message, result.Headers); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null) { var eventName = $"Consumed from {consumeContext.TopicName}, partition {consumeContext.Partition}"; var operationName = $"Consume {consumeContext.TopicName}"; var telemetryEvent = new EventTelemetry(eventName); telemetryEvent.Properties.Add("Topic", consumeContext.TopicName); telemetryEvent.Properties.Add("Offset", consumeContext.Offset.ToString()); telemetryEvent.Properties.Add("Partition", consumeContext.Partition.ToString()); NetStreamResult response; using (_client.StartOperation <RequestTelemetry>(operationName)) { response = await base.Execute(consumeContext, token, result); _client.TrackEvent(telemetryEvent); _client.GetMetric( $"Lag:{consumeContext.ConsumeGroup}:{consumeContext.TopicName}:{consumeContext.Partition}") .TrackValue(consumeContext.Lag); } return(response); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result) { _handle(consumeContext); if (Next != null) { return(await Next.Execute(consumeContext, token, new NetStreamResult(null))); } return(new NetStreamResult(result.Message)); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result) { if (result != null && result.HasValue && _writer != null) { await _writer.WriteAsync(result); } return(await base.Next.Execute(consumeContext, token, result)); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null) { var doesValueExist = consumeContext.Headers.Any(header => header.Key == CorrelationHeader.Value); if (!doesValueExist) { result.Headers.Add(new KeyValuePair <string, string>(CorrelationHeader.Value, Guid.NewGuid().ToString())); } else { result.Headers.Add(new KeyValuePair <string, string>(CorrelationHeader.Value, consumeContext.Headers.First(header => header.Key == CorrelationHeader.Value).Value)); } return(await base.Execute(consumeContext, token, result)); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result) { List.Add(consumeContext.Message); return(await Next.Execute(consumeContext, token, result)); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null) { _handle(consumeContext); return(await base.Next.Execute(consumeContext, token, result)); }
public override Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null) { return(Task.FromResult(result)); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null) { if (Next != null) { return(await Next.Execute(consumeContext, token, result)); } _consumer.Commit(); return(result); }
public override async Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result) { var response = await _handle(consumeContext); return(await this.Next.Execute(consumeContext, token, new NetStreamResult(response))); }