public override async Task <object> DeserializeResponseAsync(ITransportSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default) { if (!response.Success || response.HttpStatusCode == 404) { return(await builtInSerializer.DeserializeAsync <CatResponse <TCatRecord> >(stream, ctx).ConfigureAwait(false)); } var catResponse = new CatResponse <TCatRecord>(); var records = await builtInSerializer.DeserializeAsync <IReadOnlyCollection <TCatRecord> >(stream, ctx).ConfigureAwait(false); catResponse.Records = records; return(catResponse); }
private async Task MessageHandler(ProcessMessageEventArgs args) { try { _logger.LogInformation($"client '{_systemInfo.ClientId}' received message '{args.Message.MessageId}'. Processing..."); var message = await _messageParser.DeserializeAsync <TM>(args.Message.Body); await _messageProcessor.ProcessAsync((dynamic)message, args.CancellationToken); await args.CompleteMessageAsync(args.Message).ConfigureAwait(false); } catch (Exception ex) { _logger.LogError(ex, $"an error has occurred while processing message '{args.Message.MessageId}': {ex.Message}"); if (args.Message.DeliveryCount > 3) { await args.DeadLetterMessageAsync(args.Message).ConfigureAwait(false); } else { await args.AbandonMessageAsync(args.Message).ConfigureAwait(false); } } }
public override async Task <object> DeserializeResponseAsync( ITransportSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default ) => response.Success ? new PreviewDatafeedResponse <TDocument> { Data = await builtInSerializer.DeserializeAsync <IReadOnlyCollection <TDocument> >(stream, ctx).ConfigureAwait(false) } : new PreviewDatafeedResponse <TDocument>();
public override async Task <object> DeserializeResponseAsync( ITransportSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default ) => response.Success ? new TranslateSqlResponse { Result = await builtInSerializer.DeserializeAsync <ISearchRequest>(stream, ctx).ConfigureAwait(false) } : new TranslateSqlResponse();
public override async Task <object> DeserializeResponseAsync( ITransportSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default ) => response.Success ? new GetCertificatesResponse { Certificates = await builtInSerializer.DeserializeAsync <ClusterCertificateInformation[]>(stream, ctx).ConfigureAwait(false) } : new GetCertificatesResponse();
public override async Task <object> DeserializeResponseAsync(ITransportSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default) { if (response.Success) { if (builtInSerializer is IInternalSerializer internalSerializer && internalSerializer.TryGetJsonFormatter(out var formatter)) { var sourceSerializer = formatter.GetConnectionSettings().SourceSerializer; return(new SourceResponse <TDocument> { Body = await sourceSerializer.DeserializeAsync <TDocument>(stream, ctx).ConfigureAwait(false) }); } return(new SourceResponse <TDocument> { Body = await builtInSerializer.DeserializeAsync <TDocument>(stream, ctx).ConfigureAwait(false) }); } return(new SourceResponse <TDocument>()); }
/// <inheritdoc /> public Task <T> AsAsync <T>(CancellationToken ct = default) { using (var ms = _memoryStreamFactory.Create(Bytes)) return(_sourceSerializer.DeserializeAsync <T>(ms, ct)); }
/// <inheritdoc cref="ITransportSerializer.DeserializeAsync"/>> public Task <object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default) { using (DiagnosticSource.Diagnose(DiagnosticSources.Serializer.Deserialize, _state)) return(_serializer.DeserializeAsync(type, stream, cancellationToken)); }