예제 #1
0
        public void ShutdownAndNotify(BatchCompletionDelegate callback, CompletionQueueSafeHandle completionQueue)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            Native.grpcsharp_server_shutdown_and_notify_callback(this, completionQueue, ctx);
        }
예제 #2
0
        public void RequestCall(BatchCompletionDelegate callback, CompletionQueueSafeHandle completionQueue)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            Native.grpcsharp_server_request_call(this, completionQueue, ctx).CheckOk();
        }
예제 #3
0
        public void RegisterBatchCompletion(BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
        {
            // TODO(jtattermusch): get rid of new delegate creation here
            OpCompletionDelegate opCallback = ((success) => HandleBatchCompletion(success, ctx, callback));

            Register(ctx.Handle, opCallback);
        }
예제 #4
0
        public void StartDuplexStreaming(BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray).CheckOk();
        }
예제 #5
0
        public void StartSendStatusFromServer(Status status, BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, status.Detail).CheckOk();
        }
예제 #6
0
        public void StartSendCloseFromClient(BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_send_close_from_client(this, ctx).CheckOk();
        }
예제 #7
0
        public void StartServerSide(BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_start_serverside(this, ctx).CheckOk();
        }
예제 #8
0
        public void StartReceiveMessage(BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_recv_message(this, ctx).CheckOk();
        }
예제 #9
0
        public void StartSendInitialMetadata(BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_send_initial_metadata(this, ctx, metadataArray).CheckOk();
        }
예제 #10
0
        public void StartSendStatusFromServer(BatchCompletionDelegate callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, status.Detail, metadataArray, sendEmptyInitialMetadata).CheckOk();
        }
예제 #11
0
        public void StartSendMessage(BatchCompletionDelegate callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata).CheckOk();
        }
예제 #12
0
        public void StartServerStreaming(byte[] payload, BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray).CheckOk();
        }
예제 #13
0
        public void StartSendMessage(byte[] payload, BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length)).CheckOk();
        }
예제 #14
0
        public void RequestCall(BatchCompletionDelegate callback, GrpcEnvironment environment)
        {
            var ctx = BatchContextSafeHandle.Create();

            environment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            pinvoke.grpcsharp_server_request_call(this, environment.CompletionQueue, ctx).CheckOk();
        }
예제 #15
0
 public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq,
     CompletionRegistry completionRegistry, BatchCompletionDelegate callback)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     Native.grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx);
 }
예제 #16
0
        public void RequestCall(CompletionQueueSafeHandle cq, BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            GrpcEnvironment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_server_request_call(this, cq, ctx).CheckOk();
        }
예제 #17
0
        public void StartClientStreaming(BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
        {
            var ctx = BatchContextSafeHandle.Create();

            GrpcEnvironment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_start_client_streaming(this, ctx, metadataArray).CheckOk();
        }
예제 #18
0
        public void ShutdownAndNotify(CompletionQueueSafeHandle cq, BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            GrpcEnvironment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_server_shutdown_and_notify_callback(this, cq, ctx);
        }
예제 #19
0
        public void StartUnary(byte[] payload, BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
        {
            var ctx = BatchContextSafeHandle.Create();

            GrpcEnvironment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray)
            .CheckOk();
        }
예제 #20
0
        public BatchContextSafeHandle RegisterBatchCompletion(BatchCompletionDelegate callback, object state)
        {
            var ctx = batchContextFactory();

            ctx.SetCompletionCallback(callback, state);
            Register(ctx.Handle, ctx);
            return(ctx);
        }
예제 #21
0
        public void StartUnary(BatchCompletionDelegate callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags)
            .CheckOk();
        }
예제 #22
0
        public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq,
                                           CompletionRegistry completionRegistry, BatchCompletionDelegate callback)
        {
            var ctx = BatchContextSafeHandle.Create();

            completionRegistry.RegisterBatchCompletion(ctx, callback);
            grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx);
        }
예제 #23
0
 public void ShutdownAndNotify(BatchCompletionDelegate callback, CompletionQueueSafeHandle completionQueue)
 {
     using (completionQueue.NewScope())
     {
         var ctx = BatchContextSafeHandle.Create();
         completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
         Native.grpcsharp_server_shutdown_and_notify_callback(this, completionQueue, ctx);
     }
 }
예제 #24
0
 public void ShutdownAndNotify(BatchCompletionDelegate callback, CompletionQueueSafeHandle completionQueue)
 {
     using (completionQueue.NewScope())
     {
         // TODO(jtattermusch): delegate allocation by caller can be avoided by utilizing the "state" object,
         // but server shutdown isn't worth optimizing right now.
         var ctx = completionQueue.CompletionRegistry.RegisterBatchCompletion(callback, null);
         Native.grpcsharp_server_shutdown_and_notify_callback(this, completionQueue, ctx);
     }
 }
예제 #25
0
        /// <summary>
        /// Returned tasks completes once channel state has become different from
        /// given lastObservedState.
        /// If deadline is reached or and error occurs, returned task is cancelled.
        /// </summary>
        public IObservable <bool> WaitForStateChangedAsync(ChannelState lastObservedState, DateTime?deadline = null)
        {
            GrpcPreconditions.CheckArgument(lastObservedState != ChannelState.Shutdown,
                                            "Shutdown is a terminal state. No further state changes can occur.");
            var subject          = new AsyncSubject <bool>();
            var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture;
            var handler          = new BatchCompletionDelegate((success, ctx) =>
            {
                subject.OnNext(success);
                subject.OnCompleted();
            });

            handle.WatchConnectivityState(lastObservedState, deadlineTimespec, completionQueue, handler);
            return(subject);
        }
예제 #26
0
 void IOpCompletionCallback.OnComplete(bool success)
 {
     try
     {
         CompletionCallback(success, this);
     }
     catch (Exception e)
     {
         Logger.Error(e, "Exception occured while invoking batch completion delegate.");
     }
     finally
     {
         CompletionCallback = null;
         Dispose();
     }
 }
예제 #27
0
 private static void HandleBatchCompletion(bool success, BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
 {
     try
     {
         callback(success, ctx);
     }
     catch (Exception e)
     {
         Logger.Error(e, "Exception occured while invoking completion delegate.");
     }
     finally
     {
         if (ctx != null)
         {
             ctx.Dispose();
         }
     }
 }
예제 #28
0
 private static void HandleBatchCompletion(bool success, BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
 {
     try
     {
         callback(success, ctx);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception occured while invoking completion delegate: " + e);
     }
     finally
     {
         if (ctx != null)
         {
             ctx.Dispose();
         }
     }
 }
예제 #29
0
        /// <summary>
        /// Returned tasks completes once channel state has become different from
        /// given lastObservedState.
        /// If deadline is reached or and error occurs, returned task is cancelled.
        /// </summary>
        public Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime?deadline = null)
        {
            Preconditions.CheckArgument(lastObservedState != ChannelState.FatalFailure,
                                        "FatalFailure is a terminal state. No further state changes can occur.");
            var tcs = new TaskCompletionSource <object>();
            var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture;
            var handler          = new BatchCompletionDelegate((success, ctx) =>
            {
                if (success)
                {
                    tcs.SetResult(null);
                }
                else
                {
                    tcs.SetCanceled();
                }
            });

            handle.WatchConnectivityState(lastObservedState, deadlineTimespec, environment.CompletionQueue, environment.CompletionRegistry, handler);
            return(tcs.Task);
        }
예제 #30
0
 public void StartUnary(byte[] payload, BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_start_unary(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray)
         .CheckOk();
 }
예제 #31
0
 private static void HandleBatchCompletion(bool success, BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
 {
     try
     {
         callback(success, ctx);
     }
     catch (Exception e)
     {
         Logger.Error(e, "Exception occured while invoking batch completion delegate.");
     }
     finally
     {
         if (ctx != null)
         {
             ctx.Dispose();
         }
     }
 }
예제 #32
0
 public void RequestCall(BatchCompletionDelegate callback, CompletionQueueSafeHandle completionQueue)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionQueue.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
     Native.grpcsharp_server_request_call(this, completionQueue, ctx).CheckOk();
 }
예제 #33
0
 public void StartReceiveMessage(BatchCompletionDelegate callback)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_recv_message(this, ctx).CheckOk();
 }
예제 #34
0
 public void RegisterBatchCompletion(BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
 {
     OpCompletionDelegate opCallback = ((success) => HandleBatchCompletion(success, ctx, callback));
     Register(ctx.Handle, opCallback);
 }
예제 #35
0
 public void StartSendMessage(BatchCompletionDelegate callback, byte[] payload, WriteFlags writeFlags, bool sendEmptyInitialMetadata)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length), writeFlags, sendEmptyInitialMetadata).CheckOk();
 }
예제 #36
0
 public void ShutdownAndNotify(BatchCompletionDelegate callback, GrpcEnvironment environment)
 {
     var ctx = BatchContextSafeHandle.Create();
     environment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_server_shutdown_and_notify_callback(this, environment.CompletionQueue, ctx);
 }
예제 #37
0
 public void StartSendMessage(byte[] payload, BatchCompletionDelegate callback)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_send_message(this, ctx, payload, new UIntPtr((ulong)payload.Length)).CheckOk();
 }
예제 #38
0
 public void StartSendStatusFromServer(Status status, BatchCompletionDelegate callback)
 {
     var ctx = BatchContextSafeHandle.Create();
     GrpcEnvironment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, status.Detail).CheckOk();
 }
예제 #39
0
 public void StartServerSide(BatchCompletionDelegate callback)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_start_serverside(this, ctx).CheckOk();
 }
예제 #40
0
 public CompletionCallbackData(BatchCompletionDelegate callback, object state)
 {
     this.Callback = callback;
     this.State    = state;
 }
예제 #41
0
 public void StartServerStreaming(BatchCompletionDelegate callback, byte[] payload, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_start_server_streaming(this, ctx, payload, new UIntPtr((ulong)payload.Length), metadataArray, writeFlags).CheckOk();
 }
예제 #42
0
 public void StartDuplexStreaming(BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_start_duplex_streaming(this, ctx, metadataArray).CheckOk();
 }
예제 #43
0
 public void SetCompletionCallback(BatchCompletionDelegate callback, object state)
 {
     GrpcPreconditions.CheckState(completionCallbackData.Callback == null);
     GrpcPreconditions.CheckNotNull(callback, nameof(callback));
     completionCallbackData = new CompletionCallbackData(callback, state);
 }
예제 #44
0
 public void StartClientStreaming(BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
 {
     var ctx = BatchContextSafeHandle.Create();
     GrpcEnvironment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_start_client_streaming(this, ctx, metadataArray).CheckOk();
 }
예제 #45
0
 public void StartSendStatusFromServer(BatchCompletionDelegate callback, Status status, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_send_status_from_server(this, ctx, status.StatusCode, status.Detail, metadataArray, sendEmptyInitialMetadata).CheckOk();
 }
예제 #46
0
 public void RequestCall(BatchCompletionDelegate callback, GrpcEnvironment environment)
 {
     var ctx = BatchContextSafeHandle.Create();
     environment.CompletionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_server_request_call(this, environment.CompletionQueue, ctx).CheckOk();
 }
예제 #47
0
 public void StartSendInitialMetadata(BatchCompletionDelegate callback, MetadataArraySafeHandle metadataArray)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_send_initial_metadata(this, ctx, metadataArray).CheckOk();
 }
예제 #48
0
파일: Channel.cs 프로젝트: ELMERzark/grpc
 /// <summary>
 /// Returned tasks completes once channel state has become different from 
 /// given lastObservedState. 
 /// If deadline is reached or and error occurs, returned task is cancelled.
 /// </summary>
 public Task WaitForStateChangedAsync(ChannelState lastObservedState, DateTime? deadline = null)
 {
     Preconditions.CheckArgument(lastObservedState != ChannelState.FatalFailure,
         "FatalFailure is a terminal state. No further state changes can occur.");
     var tcs = new TaskCompletionSource<object>();
     var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture;
     var handler = new BatchCompletionDelegate((success, ctx) =>
     {
         if (success)
         {
             tcs.SetResult(null);
         }
         else
         {
             tcs.SetCanceled();
         }
     });
     handle.WatchConnectivityState(lastObservedState, deadlineTimespec, environment.CompletionQueue, environment.CompletionRegistry, handler);
     return tcs.Task;
 }
예제 #49
0
        public void RegisterBatchCompletion(BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
        {
            OpCompletionDelegate opCallback = ((success) => HandleBatchCompletion(success, ctx, callback));

            Register(ctx.Handle, opCallback);
        }
예제 #50
0
 private static void HandleBatchCompletion(bool success, BatchContextSafeHandle ctx, BatchCompletionDelegate callback)
 {
     try
     {
         callback(success, ctx);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception occured while invoking completion delegate: " + e);
     }
     finally
     {
         if (ctx != null)
         {
             ctx.Dispose();
         }
     }
 }
예제 #51
0
 public void StartSendCloseFromClient(BatchCompletionDelegate callback)
 {
     var ctx = BatchContextSafeHandle.Create();
     completionRegistry.RegisterBatchCompletion(ctx, callback);
     grpcsharp_call_send_close_from_client(this, ctx).CheckOk();
 }