From a5272b6adc5fb7e8c71b7216b0f5e690980a79b2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 30 Apr 2015 11:56:46 -0700 Subject: A new version C# API based on async/await --- src/csharp/Grpc.Core/Grpc.Core.csproj | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/csharp/Grpc.Core/Grpc.Core.csproj') diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index 0b85392e15..fee742b220 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -39,12 +39,18 @@ + + + + + + - + @@ -59,14 +65,10 @@ - - - - - + @@ -86,6 +88,12 @@ + + + + + + -- cgit v1.2.3 From 1b54fcf31b32ae8c7f07ae733e781c184791a7c2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 1 May 2015 14:30:16 -0700 Subject: added stats with number of active native calls, useful for debugging --- src/csharp/Grpc.Core/Grpc.Core.csproj | 4 +- src/csharp/Grpc.Core/GrpcEnvironment.cs | 16 +++++++ src/csharp/Grpc.Core/Internal/AsyncCall.cs | 6 +++ src/csharp/Grpc.Core/Internal/AsyncCallBase.cs | 5 ++ src/csharp/Grpc.Core/Internal/AsyncCallServer.cs | 6 +++ src/csharp/Grpc.Core/Internal/AtomicCounter.cs | 61 ++++++++++++++++++++++++ src/csharp/Grpc.Core/Internal/DebugStats.cs | 45 +++++++++++++++++ 7 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 src/csharp/Grpc.Core/Internal/AtomicCounter.cs create mode 100644 src/csharp/Grpc.Core/Internal/DebugStats.cs (limited to 'src/csharp/Grpc.Core/Grpc.Core.csproj') diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index fee742b220..9c91541d90 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -5,7 +5,7 @@ Debug AnyCPU - 10.0.0 + 8.0.30703 2.0 {CCC4440E-49F7-4790-B0AF-FEABB0837AE7} Library @@ -94,6 +94,8 @@ + + diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs index 9c10a42e23..2e9e5a2ef6 100644 --- a/src/csharp/Grpc.Core/GrpcEnvironment.cs +++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs @@ -86,6 +86,8 @@ namespace Grpc.Core { instance.Close(); instance = null; + + CheckDebugStats(); } } } @@ -132,5 +134,19 @@ namespace Grpc.Core // TODO: use proper logging here Console.WriteLine("GRPC shutdown."); } + + private static void CheckDebugStats() + { + var remainingClientCalls = DebugStats.ActiveClientCalls.Count; + if (remainingClientCalls != 0) + { + Console.WriteLine("Warning: Detected {0} client calls that weren't disposed properly.", remainingClientCalls); + } + var remainingServerCalls = DebugStats.ActiveServerCalls.Count; + if (remainingServerCalls != 0) + { + Console.WriteLine("Warning: Detected {0} server calls that weren't disposed properly.", remainingServerCalls); + } + } } } diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index fd94771ddd..3532f7347a 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -67,6 +67,7 @@ namespace Grpc.Core.Internal public void Initialize(Channel channel, CompletionQueueSafeHandle cq, string methodName) { var call = CallSafeHandle.Create(channel.Handle, cq, methodName, channel.Target, Timespec.InfFuture); + DebugStats.ActiveClientCalls.Increment(); InitializeInternal(call); } @@ -265,6 +266,11 @@ namespace Grpc.Core.Internal } } + protected override void OnReleaseResources() + { + DebugStats.ActiveClientCalls.Decrement(); + } + /// /// Handler for unary response completion. /// diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 2bde4b3720..b911cdcc87 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -191,6 +191,7 @@ namespace Grpc.Core.Internal private void ReleaseResources() { + OnReleaseResources(); if (call != null) { call.Dispose(); @@ -199,6 +200,10 @@ namespace Grpc.Core.Internal disposed = true; } + protected virtual void OnReleaseResources() + { + } + protected void CheckSendingAllowed() { Preconditions.CheckState(started); diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index 449009336f..4775f2d07b 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -57,6 +57,7 @@ namespace Grpc.Core.Internal public void Initialize(CallSafeHandle call) { + DebugStats.ActiveServerCalls.Increment(); InitializeInternal(call); } @@ -112,6 +113,11 @@ namespace Grpc.Core.Internal } } + protected override void OnReleaseResources() + { + DebugStats.ActiveServerCalls.Decrement(); + } + /// /// Handles the server side close completion. /// diff --git a/src/csharp/Grpc.Core/Internal/AtomicCounter.cs b/src/csharp/Grpc.Core/Internal/AtomicCounter.cs new file mode 100644 index 0000000000..7ccda225dc --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/AtomicCounter.cs @@ -0,0 +1,61 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; +using System.Threading; + +namespace Grpc.Core.Internal +{ + internal class AtomicCounter + { + long counter = 0; + + public void Increment() + { + Interlocked.Increment(ref counter); + } + + public void Decrement() + { + Interlocked.Decrement(ref counter); + } + + public long Count + { + get + { + return counter; + } + } + } +} diff --git a/src/csharp/Grpc.Core/Internal/DebugStats.cs b/src/csharp/Grpc.Core/Internal/DebugStats.cs new file mode 100644 index 0000000000..476914f751 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/DebugStats.cs @@ -0,0 +1,45 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; +using System.Threading; + +namespace Grpc.Core.Internal +{ + internal static class DebugStats + { + public static readonly AtomicCounter ActiveClientCalls = new AtomicCounter(); + + public static readonly AtomicCounter ActiveServerCalls = new AtomicCounter(); + } +} -- cgit v1.2.3 From 8ab1f7ed3d2f8af7702df95139a6b62aa76b5f0e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 6 May 2015 15:56:30 -0700 Subject: added concept of ServerCallContext, that is passed to all server-side handlers --- src/csharp/Grpc.Core.Tests/ClientServerTest.cs | 4 +- src/csharp/Grpc.Core/Grpc.Core.csproj | 1 + src/csharp/Grpc.Core/Internal/ServerCallHandler.cs | 12 +++-- src/csharp/Grpc.Core/ServerCallContext.cs | 56 ++++++++++++++++++++++ src/csharp/Grpc.Core/ServerMethods.cs | 8 ++-- src/csharp/Grpc.Examples/MathGrpc.cs | 8 ++-- src/csharp/Grpc.Examples/MathServiceImpl.cs | 8 ++-- .../Grpc.IntegrationTesting/TestServiceGrpc.cs | 12 ++--- .../Grpc.IntegrationTesting/TestServiceImpl.cs | 12 ++--- 9 files changed, 91 insertions(+), 30 deletions(-) create mode 100644 src/csharp/Grpc.Core/ServerCallContext.cs (limited to 'src/csharp/Grpc.Core/Grpc.Core.csproj') diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs index caa6220f2c..4eb542fae8 100644 --- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs +++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs @@ -220,7 +220,7 @@ namespace Grpc.Core.Tests } } - private static async Task EchoHandler(string request) + private static async Task EchoHandler(ServerCallContext context, string request) { if (request == "THROW") { @@ -229,7 +229,7 @@ namespace Grpc.Core.Tests return request; } - private static async Task ConcatAndEchoHandler(IAsyncStreamReader requestStream) + private static async Task ConcatAndEchoHandler(ServerCallContext context, IAsyncStreamReader requestStream) { string result = ""; await requestStream.ForEach(async (request) => diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index 9c91541d90..f5f2cf5f22 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -96,6 +96,7 @@ + diff --git a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs index 2bef6e68b7..95d8e97869 100644 --- a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs +++ b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs @@ -74,7 +74,8 @@ namespace Grpc.Core.Internal var request = await requestStream.ReadNext(); // TODO(jtattermusch): we need to read the full stream so that native callhandle gets deallocated. Preconditions.CheckArgument(await requestStream.ReadNext() == null); - var result = await handler(request); + var context = new ServerCallContext(); // TODO(jtattermusch): initialize the context + var result = await handler(context, request); await responseStream.Write(result); } catch (Exception e) @@ -125,7 +126,8 @@ namespace Grpc.Core.Internal // TODO(jtattermusch): we need to read the full stream so that native callhandle gets deallocated. Preconditions.CheckArgument(await requestStream.ReadNext() == null); - await handler(request, responseStream); + var context = new ServerCallContext(); // TODO(jtattermusch): initialize the context + await handler(context, request, responseStream); } catch (Exception e) { @@ -168,11 +170,12 @@ namespace Grpc.Core.Internal var finishedTask = asyncCall.ServerSideCallAsync(); var requestStream = new ServerRequestStream(asyncCall); var responseStream = new ServerResponseStream(asyncCall); + var context = new ServerCallContext(); // TODO(jtattermusch): initialize the context Status status = Status.DefaultSuccess; try { - var result = await handler(requestStream); + var result = await handler(context, requestStream); try { await responseStream.Write(result); @@ -223,11 +226,12 @@ namespace Grpc.Core.Internal var finishedTask = asyncCall.ServerSideCallAsync(); var requestStream = new ServerRequestStream(asyncCall); var responseStream = new ServerResponseStream(asyncCall); + var context = new ServerCallContext(); // TODO(jtattermusch): initialize the context Status status = Status.DefaultSuccess; try { - await handler(requestStream, responseStream); + await handler(context, requestStream, responseStream); } catch (Exception e) { diff --git a/src/csharp/Grpc.Core/ServerCallContext.cs b/src/csharp/Grpc.Core/ServerCallContext.cs new file mode 100644 index 0000000000..e873b3e88a --- /dev/null +++ b/src/csharp/Grpc.Core/ServerCallContext.cs @@ -0,0 +1,56 @@ +#region Copyright notice and license + +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Grpc.Core +{ + /// + /// Context for a server-side call. + /// + public sealed class ServerCallContext + { + + // TODO(jtattermusch): add cancellationToken + + // TODO(jtattermusch): add deadline info + + // TODO(jtattermusch): expose initial metadata sent by client for reading + + // TODO(jtattermusch): expose method to send initial metadata back to client + + // TODO(jtattermusch): allow setting status and trailing metadata to send after handler completes. + } +} diff --git a/src/csharp/Grpc.Core/ServerMethods.cs b/src/csharp/Grpc.Core/ServerMethods.cs index 291835671f..377b78eb30 100644 --- a/src/csharp/Grpc.Core/ServerMethods.cs +++ b/src/csharp/Grpc.Core/ServerMethods.cs @@ -42,28 +42,28 @@ namespace Grpc.Core /// /// Server-side handler for unary call. /// - public delegate Task UnaryServerMethod(TRequest request) + public delegate Task UnaryServerMethod(ServerCallContext context, TRequest request) where TRequest : class where TResponse : class; /// /// Server-side handler for client streaming call. /// - public delegate Task ClientStreamingServerMethod(IAsyncStreamReader requestStream) + public delegate Task ClientStreamingServerMethod(ServerCallContext context, IAsyncStreamReader requestStream) where TRequest : class where TResponse : class; /// /// Server-side handler for server streaming call. /// - public delegate Task ServerStreamingServerMethod(TRequest request, IServerStreamWriter responseStream) + public delegate Task ServerStreamingServerMethod(ServerCallContext context, TRequest request, IServerStreamWriter responseStream) where TRequest : class where TResponse : class; /// /// Server-side handler for bidi streaming call. /// - public delegate Task DuplexStreamingServerMethod(IAsyncStreamReader requestStream, IServerStreamWriter responseStream) + public delegate Task DuplexStreamingServerMethod(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream) where TRequest : class where TResponse : class; } diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index 60408b9018..03f5c31cb7 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -133,13 +133,13 @@ namespace math // server-side interface public interface IMathService { - Task Div(DivArgs request); + Task Div(ServerCallContext context, DivArgs request); - Task Fib(FibArgs request, IServerStreamWriter responseStream); + Task Fib(ServerCallContext context, FibArgs request, IServerStreamWriter responseStream); - Task Sum(IAsyncStreamReader requestStream); + Task Sum(ServerCallContext context, IAsyncStreamReader requestStream); - Task DivMany(IAsyncStreamReader requestStream, IServerStreamWriter responseStream); + Task DivMany(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream); } public static ServerServiceDefinition BindService(IMathService serviceImpl) diff --git a/src/csharp/Grpc.Examples/MathServiceImpl.cs b/src/csharp/Grpc.Examples/MathServiceImpl.cs index 83ec2a8c3d..800dee8735 100644 --- a/src/csharp/Grpc.Examples/MathServiceImpl.cs +++ b/src/csharp/Grpc.Examples/MathServiceImpl.cs @@ -46,12 +46,12 @@ namespace math /// public class MathServiceImpl : MathGrpc.IMathService { - public Task Div(DivArgs request) + public Task Div(ServerCallContext context, DivArgs request) { return Task.FromResult(DivInternal(request)); } - public async Task Fib(FibArgs request, IServerStreamWriter responseStream) + public async Task Fib(ServerCallContext context, FibArgs request, IServerStreamWriter responseStream) { if (request.Limit <= 0) { @@ -68,7 +68,7 @@ namespace math } } - public async Task Sum(IAsyncStreamReader requestStream) + public async Task Sum(ServerCallContext context, IAsyncStreamReader requestStream) { long sum = 0; await requestStream.ForEach(async num => @@ -78,7 +78,7 @@ namespace math return Num.CreateBuilder().SetNum_(sum).Build(); } - public async Task DivMany(IAsyncStreamReader requestStream, IServerStreamWriter responseStream) + public async Task DivMany(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream) { await requestStream.ForEach(async divArgs => { diff --git a/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs index d1f8aa12c7..9f14dad6c0 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs @@ -171,17 +171,17 @@ namespace grpc.testing // server-side interface public interface ITestService { - Task EmptyCall(Empty request); + Task EmptyCall(ServerCallContext context, Empty request); - Task UnaryCall(SimpleRequest request); + Task UnaryCall(ServerCallContext context, SimpleRequest request); - Task StreamingOutputCall(StreamingOutputCallRequest request, IServerStreamWriter responseStream); + Task StreamingOutputCall(ServerCallContext context, StreamingOutputCallRequest request, IServerStreamWriter responseStream); - Task StreamingInputCall(IAsyncStreamReader requestStream); + Task StreamingInputCall(ServerCallContext context, IAsyncStreamReader requestStream); - Task FullDuplexCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream); + Task FullDuplexCall(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream); - Task HalfDuplexCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream); + Task HalfDuplexCall(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream); } public static ServerServiceDefinition BindService(ITestService serviceImpl) diff --git a/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs index 8b0cf3a2d0..40f32b5a88 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestServiceImpl.cs @@ -46,19 +46,19 @@ namespace grpc.testing /// public class TestServiceImpl : TestServiceGrpc.ITestService { - public Task EmptyCall(Empty request) + public Task EmptyCall(ServerCallContext context, Empty request) { return Task.FromResult(Empty.DefaultInstance); } - public Task UnaryCall(SimpleRequest request) + public Task UnaryCall(ServerCallContext context, SimpleRequest request) { var response = SimpleResponse.CreateBuilder() .SetPayload(CreateZerosPayload(request.ResponseSize)).Build(); return Task.FromResult(response); } - public async Task StreamingOutputCall(StreamingOutputCallRequest request, IServerStreamWriter responseStream) + public async Task StreamingOutputCall(ServerCallContext context, StreamingOutputCallRequest request, IServerStreamWriter responseStream) { foreach (var responseParam in request.ResponseParametersList) { @@ -68,7 +68,7 @@ namespace grpc.testing } } - public async Task StreamingInputCall(IAsyncStreamReader requestStream) + public async Task StreamingInputCall(ServerCallContext context, IAsyncStreamReader requestStream) { int sum = 0; await requestStream.ForEach(async request => @@ -78,7 +78,7 @@ namespace grpc.testing return StreamingInputCallResponse.CreateBuilder().SetAggregatedPayloadSize(sum).Build(); } - public async Task FullDuplexCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream) + public async Task FullDuplexCall(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream) { await requestStream.ForEach(async request => { @@ -91,7 +91,7 @@ namespace grpc.testing }); } - public async Task HalfDuplexCall(IAsyncStreamReader requestStream, IServerStreamWriter responseStream) + public async Task HalfDuplexCall(ServerCallContext context, IAsyncStreamReader requestStream, IServerStreamWriter responseStream) { throw new NotImplementedException(); } -- cgit v1.2.3