private Task <GetSelectorsResponse> GetSelectorsAsync(GetSelectorsRequest request, ServerCallContext context) { return(PerformOperationAsync( request, async c => { Fingerprint fingerprint = request.WeakFingerprint.DeserializeFingerprintFromGrpc(); if (c.Session is IReadOnlyMemoizationSessionWithLevelSelectors withSelectors) { var result = await withSelectors.GetLevelSelectorsAsync(c.Context, fingerprint, c.Context.Token, request.Level).ThrowIfFailure(); var selectors = result.Value.Selectors.Select(s => s.ToGrpc()); return new GetSelectorsResponse(result.Value.HasMore, selectors); } throw new NotSupportedException($"Session {c.Session.GetType().Name} does not support {nameof(GetSelectorsAsync)} functionality."); }, context.CancellationToken)); }
/// <summary> /// Get selectors for weak fingerprint /// </summary> public Task <Result <LevelSelectors> > GetLevelSelectorsAsync(OperationContext context, Fingerprint weakFingerprint, int level) { return(PerformOperationAsync( context, async sessionContext => { var request = new GetSelectorsRequest() { Header = new RequestHeader(context.TracingContext.TraceId, sessionContext.SessionId), WeakFingerprint = FromGrpc(weakFingerprint), Level = level, }; GetSelectorsResponse response = await SendGrpcRequestAndThrowIfFailedAsync( sessionContext, async() => await Client.GetSelectorsAsync(request)); return response.FromGrpc(); })); }
/// <inheritdoc /> public override Task <GetSelectorsResponse> GetSelectors(GetSelectorsRequest request, ServerCallContext context) => _server.GetSelectorsAsync(request, context);