AsyncDuplexStreamingCall <TRequest, TResponse>(Method <TRequest, TResponse> method, string host, CallOptions options) { // No channel affinity feature for duplex streaming call. ChannelRef channelRef = GetChannelRef(); var originalCall = channelRef.CallInvoker.AsyncDuplexStreamingCall(method, host, options); // Decrease the active streams count once the streaming response finishes its final batch. var gcpResponseStream = new GcpClientResponseStream <TRequest, TResponse>( originalCall.ResponseStream, (resp) => channelRef.ActiveStreamCountDecr()); // Create a wrapper of the original AsyncDuplexStreamingCall. return(new AsyncDuplexStreamingCall <TRequest, TResponse>( originalCall.RequestStream, gcpResponseStream, originalCall.ResponseHeadersAsync, () => originalCall.GetStatus(), () => originalCall.GetTrailers(), () => originalCall.Dispose())); }
AsyncServerStreamingCall <TRequest, TResponse>(Method <TRequest, TResponse> method, string host, CallOptions options, TRequest request) { _affinityByMethod.TryGetValue(method.FullName, out AffinityConfig affinityConfig); ChannelRef channelRef = PreProcess(affinityConfig, request); var originalCall = channelRef.CallInvoker.AsyncServerStreamingCall(method, host, options, request); // Executes affinity postprocess once the streaming response finishes its final batch. var gcpResponseStream = new GcpClientResponseStream <TRequest, TResponse>( originalCall.ResponseStream, (resp) => PostProcess(affinityConfig, channelRef, request, resp)); // Create a wrapper of the original AsyncServerStreamingCall. return(new AsyncServerStreamingCall <TResponse>( gcpResponseStream, originalCall.ResponseHeadersAsync, () => originalCall.GetStatus(), () => originalCall.GetTrailers(), () => originalCall.Dispose())); }