コード例 #1
0
 public PushUnaryContent(TRequest content, GrpcCall <TRequest, TResponse> call, string grpcEncoding, MediaTypeHeaderValue mediaType)
 {
     _content            = content;
     _call               = call;
     _grpcEncoding       = grpcEncoding;
     Headers.ContentType = mediaType;
 }
コード例 #2
0
 public HttpContentClientStreamWriter(GrpcCall <TRequest, TResponse> call, Task <Stream> writeStreamTask, TaskCompletionSource <bool> completeTcs)
 {
     _call            = call;
     _writeStreamTask = writeStreamTask;
     _completeTcs     = completeTcs;
     _writeLock       = new object();
     WriteOptions     = _call.Options.WriteOptions;
 }
コード例 #3
0
        public HttpContentClientStreamWriter(GrpcCall <TRequest, TResponse> call)
            : base(call.Channel.LoggerFactory.CreateLogger(LoggerName))
        {
            _call = call;

            WriteStreamTcs = new TaskCompletionSource <Stream>(TaskCreationOptions.RunContinuationsAsynchronously);
            CompleteTcs    = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);
            WriteOptions   = _call.Options.WriteOptions;
        }
コード例 #4
0
 public HttpContentClientStreamWriter(
     GrpcCall <TRequest, TResponse> call,
     HttpRequestMessage message)
 {
     _call          = call;
     WriteStreamTcs = new TaskCompletionSource <Stream>(TaskCreationOptions.RunContinuationsAsynchronously);
     CompleteTcs    = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);
     _writeLock     = new object();
     WriteOptions   = _call.Options.WriteOptions;
     _grpcEncoding  = GrpcProtocolHelpers.GetRequestEncoding(message.Headers);
 }
コード例 #5
0
 public HttpContentClientStreamWriter(
     GrpcCall <TRequest, TResponse> call,
     HttpRequestMessage message,
     Task <Stream> writeStreamTask,
     TaskCompletionSource <bool> completeTcs)
 {
     _call            = call;
     _writeStreamTask = writeStreamTask;
     _completeTcs     = completeTcs;
     _writeLock       = new object();
     WriteOptions     = _call.Options.WriteOptions;
     _grpcEncoding    = GrpcProtocolHelpers.GetRequestEncoding(message.Headers);
 }
コード例 #6
0
        private GrpcCall <TRequest, TResponse> CreateGrpcCall <TRequest, TResponse>(
            Method <TRequest, TResponse> method,
            CallOptions options)
            where TRequest : class
            where TResponse : class
        {
            if (Channel.Disposed)
            {
                throw new ObjectDisposedException(nameof(GrpcChannel));
            }

            var call = new GrpcCall <TRequest, TResponse>(method, options, Channel);

            return(call);
        }
コード例 #7
0
        public HttpContentClientStreamWriter(GrpcCall <TRequest, TResponse> call)
            : base(call.Channel.LoggerFactory.CreateLogger(LoggerName))
        {
            _call = call;

            // CompleteTcs doesn't use RunContinuationsAsynchronously because we want the caller of CompleteAsync
            // to wait until the TCS's awaiter, PushStreamContent, finishes completing the request.
            // This is required to avoid a race condition between the HttpContent completing, and sending an
            // END_STREAM flag to the server, and app code disposing the call, which will trigger a RST_STREAM
            // if HttpContent has finished.
            // See https://github.com/grpc/grpc-dotnet/issues/1394 for an example.
            CompleteTcs = new TaskCompletionSource <bool>(TaskCreationOptions.None);

            WriteStreamTcs = new TaskCompletionSource <Stream>(TaskCreationOptions.RunContinuationsAsynchronously);
            WriteOptions   = _call.Options.WriteOptions;
        }
コード例 #8
0
        public static GrpcCall <TRequest, TResponse> CreateGrpcCall <TRequest, TResponse>(
            GrpcChannel channel,
            Method <TRequest, TResponse> method,
            CallOptions options,
            int attempt)
            where TRequest : class
            where TResponse : class
        {
            if (channel.Disposed)
            {
                throw new ObjectDisposedException(nameof(GrpcChannel));
            }

            var methodInfo = channel.GetCachedGrpcMethodInfo(method);
            var call       = new GrpcCall <TRequest, TResponse>(method, methodInfo, options, channel, attempt);

            return(call);
        }
コード例 #9
0
 public PushUnaryContent(TRequest content, GrpcCall <TRequest, TResponse> call, MediaTypeHeaderValue mediaType)
 {
     _content            = content;
     _call               = call;
     Headers.ContentType = mediaType;
 }
コード例 #10
0
 public GrpcCallSerializationContext(GrpcCall call)
 {
     _call = call;
 }
コード例 #11
0
 static ValueTask WriteMessageToStream(GrpcCall <TRequest, TResponse> call, Stream writeStream, CallOptions callOptions, TRequest message)
 {
     return(call.WriteMessageAsync(writeStream, message, callOptions));
 }
コード例 #12
0
 public HttpContentClientStreamReader(GrpcCall <TRequest, TResponse> call)
 {
     _call         = call;
     _moveNextLock = new object();
 }