/// <summary> /// Implements a pin request. /// </summary> private async Task <PinResponse> PinAsync(PinRequest request, CancellationToken token) { LogRequestHandling(); DateTime startTime = DateTime.UtcNow; var cacheContext = new Context(new Guid(request.Header.TraceId), _logger); return(await RunFuncAndReportAsync( request.Header.SessionId, async session => { PinResult pinResult = await session.PinAsync( cacheContext, request.ContentHash.ToContentHash((HashType)request.HashType), token); return new PinResponse { Header = new ResponseHeader( startTime, pinResult.Succeeded, (int)pinResult.Code, pinResult.ErrorMessage, pinResult.Diagnostics) }; }, errorMessage => new PinResponse { Header = ResponseHeader.Failure(startTime, (int)PinResult.ResultCode.Error, errorMessage) })); }
private Task <PinResponse> PinAsync(PinRequest request, CancellationToken token) { return(RunFuncAsync( request.Header, async(context, session) => { PinResult pinResult = await session.PinAsync( context.TracingContext, request.ContentHash.ToContentHash((HashType)request.HashType), token); return new PinResponse { Header = new ResponseHeader( context.StartTime, pinResult.Succeeded, (int)pinResult.Code, pinResult.ErrorMessage, pinResult.Diagnostics) }; }, (context, errorMessage) => new PinResponse { Header = ResponseHeader.Failure(context.StartTime, (int)PinResult.ResultCode.Error, errorMessage) })); }
/// <inheritdoc /> public override Task <PinResponse> Pin(PinRequest request, ServerCallContext context) => _contentServer.PinAsync(request, context.CancellationToken);