Пример #1
0
        public async Task <ServiceResponse <TResponse> > Execute(TRequest request, CancellationToken cancellationToken)
        {
            _startTime = ServiceClock.CurrentTime();
            Logger.LogTrace(new EventId(1, "request"), JsonSerializer.Serialize(request));
            CorrelationId = request.CorrelationId;
            var response = await Run(request, cancellationToken);

            Logger.LogTrace(new EventId(2, "response"), JsonSerializer.Serialize(response));
            return(response);
        }
Пример #2
0
 public ResponseMetaData(
     string serviceName,
     Guid correlationId,
     ServiceResult serviceResult,
     long durationMs,
     DateTimeOffset?responseCreated                  = null,
     IDictionary <int, string>?errorCodes            = null,
     IDictionary <string, string[]>?validationErrors = null,
     string?publicMessage    = "",
     string?exceptionMessage = "",
     Dictionary <string, ResponseMetaData>?dependencies = null
     )
 {
     ServiceName      = serviceName;
     CorrelationId    = correlationId;
     Result           = serviceResult;
     DurationMs       = durationMs;
     PublicMessage    = string.IsNullOrWhiteSpace(publicMessage) ? null : publicMessage.Trim();
     ExceptionMessage = string.IsNullOrWhiteSpace(exceptionMessage) ? null : exceptionMessage.Trim();
     Dependencies     = dependencies;
     ErrorCodes       = errorCodes?.ToDictionary(k => k.Key.ToString(), v => v.Value);
     ValidationErrors = validationErrors;
     ResponseCreated  = responseCreated ?? ServiceClock.CurrentTime();
 }