Example #1
0
        private async Task ProcessResponsesAsync(IAsyncEnumerable <ClientResponse> responses, CancellationToken cancellationToken = default)
        {
            await foreach (var response in responses.WithCancellation(cancellationToken))
            {
                _logger.LogInformation($"Processing client response for request '{response.MetaData.RequestId}'");

                await _clientQueuedResponses.WriteAsync(response, cancellationToken).ConfigureAwait(false);
            }
        }
Example #2
0
        private async Task ProcessAsync(CancellationToken cancellationToken)
        {
            await foreach (var request in _clientQueuedRequests.ReadAsync(cancellationToken))
            {
                _logger.LogInformation($"Processing request {request}");

                var response = await _clientRequestProcessor.ProcessAsync(request, cancellationToken).ConfigureAwait(false);

                response = response with {
                    MetaData = _clientResponseMetaDataFactory.CreateNew(request.MetaData)
                };

                _logger.LogInformation($"Created response {response} for request {request}'. Sending response back to server");

                await _clientQueuedResponses.WriteAsync(response, cancellationToken).ConfigureAwait(false);
            }
        }