Exemple #1
0
        private async IAsyncEnumerable <ClientRequest> SendRequestsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
        {
            await foreach (var queuedRequest in _clientQueuedRequests.ReadAsync(cancellationToken))
            {
                _logger.LogInformation($"Sending request '{queuedRequest.Request}' to client");

                yield return(queuedRequest.Request);

                _logger.LogInformation($"Request '{queuedRequest.Request}' has been sent to the client");

                _clientPendingRequests.Write(queuedRequest);
            }
        }
Exemple #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);
            }
        }