コード例 #1
0
 public async Task WriteAsync(NetStreamResult result)
 {
     await this.WriteAsync(new NetStreamResult <TResponse>(result.Message, result.Headers));
 }
コード例 #2
0
        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));
        }
コード例 #3
0
 public async Task WriteAsync(NetStreamResult <TResponse> result)
 {
     await _producer.ProduceAsync(_resolveKey(result.Message), result.Message, result.Headers);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
ファイル: NoOpStep.cs プロジェクト: joelbrinkley/NetStreams
 public override Task <NetStreamResult> Execute(IConsumeContext <TKey, TMessage> consumeContext, CancellationToken token, NetStreamResult result = null)
 {
     return(Task.FromResult(result));
 }
コード例 #11
0
        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);
        }
コード例 #12
0
        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)));
        }