Ejemplo n.º 1
0
        /// <summary>
        /// Builds an <see cref="ApiServerStreamingCall"/> given a suitable underlying server streaming call.
        /// </summary>
        /// <typeparam name="TRequest">Request type, which must be a protobuf message.</typeparam>
        /// <typeparam name="TResponse">Response type, which must be a protobuf message.</typeparam>
        /// <param name="grpcCall">The underlying gRPC duplex streaming call.</param>
        /// <param name="perMethodCallSettings">The default method call settings.</param>
        /// <returns>An API call to proxy to the RPC calls</returns>
        public ApiServerStreamingCall <TRequest, TResponse> BuildApiCall <TRequest, TResponse>(
            Func <TRequest, CallOptions, AsyncServerStreamingCall <TResponse> > grpcCall,
            CallSettings perMethodCallSettings)
            where TRequest : class, IMessage <TRequest>
            where TResponse : class, IMessage <TResponse>
        {
            CallSettings baseCallSettings = _clientCallSettings.MergedWith(perMethodCallSettings);

            return(ApiServerStreamingCall.Create(grpcCall, baseCallSettings, Clock)
                   .WithVersionHeader(_versionHeader));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds an <see cref="ApiServerStreamingCall"/> given a suitable underlying server streaming call.
        /// </summary>
        /// <typeparam name="TRequest">Request type, which must be a protobuf message.</typeparam>
        /// <typeparam name="TResponse">Response type, which must be a protobuf message.</typeparam>
        /// <param name="grpcCall">The underlying gRPC duplex streaming call.</param>
        /// <param name="perMethodCallSettings">The default method call settings.</param>
        /// <returns>An API call to proxy to the RPC calls</returns>
        public ApiServerStreamingCall <TRequest, TResponse> BuildApiCall <TRequest, TResponse>(
            Func <TRequest, CallOptions, AsyncServerStreamingCall <TResponse> > grpcCall,
            CallSettings perMethodCallSettings)
            where TRequest : class, IMessage <TRequest>
            where TResponse : class, IMessage <TResponse>
        {
            CallSettings baseCallSettings = _clientCallSettings.MergedWith(perMethodCallSettings);

            // These operations are applied in reverse order.
            // I.e. Version header is added first, then retry is performed.
            return(ApiServerStreamingCall.Create(grpcCall, baseCallSettings, Clock)
                   .WithMergedBaseCallSettings(_versionCallSettings));
        }