Exemplo n.º 1
0
 public PushUnaryContent(TRequest content, GrpcCall <TRequest, TResponse> call, string grpcEncoding, MediaTypeHeaderValue mediaType)
 {
     _content            = content;
     _call               = call;
     _grpcEncoding       = grpcEncoding;
     Headers.ContentType = mediaType;
 }
 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;
 }
        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;
        }
 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);
 }
 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);
 }
        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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 9
0
 public PushUnaryContent(TRequest content, GrpcCall <TRequest, TResponse> call, MediaTypeHeaderValue mediaType)
 {
     _content            = content;
     _call               = call;
     Headers.ContentType = mediaType;
 }
Exemplo n.º 10
0
 public GrpcCallSerializationContext(GrpcCall call)
 {
     _call = call;
 }
Exemplo n.º 11
0
 static ValueTask WriteMessageToStream(GrpcCall <TRequest, TResponse> call, Stream writeStream, CallOptions callOptions, TRequest message)
 {
     return(call.WriteMessageAsync(writeStream, message, callOptions));
 }
 public HttpContentClientStreamReader(GrpcCall <TRequest, TResponse> call)
 {
     _call         = call;
     _moveNextLock = new object();
 }