Handle null implementations

pull/17837/head
John Luo 6 years ago committed by =
parent ad9dcc1ff4
commit 9b6389f05a
  1. 38
      src/compiler/csharp_generator.cc
  2. 54
      src/csharp/Grpc.Core/ServiceBinderBase.cs
  3. 13
      src/csharp/Grpc.Examples/MathGrpc.cs
  4. 9
      src/csharp/Grpc.HealthCheck/HealthGrpc.cs
  5. 15
      src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs
  6. 5
      src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs
  7. 9
      src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
  8. 7
      src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs
  9. 37
      src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
  10. 13
      src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs
  11. 7
      src/csharp/Grpc.Reflection/ReflectionGrpc.cs

@ -199,6 +199,21 @@ std::string GetCSharpMethodType(MethodType method_type) {
return ""; return "";
} }
std::string GetCSharpServerMethodType(MethodType method_type) {
switch (method_type) {
case METHODTYPE_NO_STREAMING:
return "grpc::UnaryServerMethod";
case METHODTYPE_CLIENT_STREAMING:
return "grpc::ClientStreamingServerMethod";
case METHODTYPE_SERVER_STREAMING:
return "grpc::ServerStreamingServerMethod";
case METHODTYPE_BIDI_STREAMING:
return "grpc::DuplexStreamingServerMethod";
}
GOOGLE_LOG(FATAL) << "Can't get here.";
return "";
}
std::string GetServiceNameFieldName() { return "__ServiceName"; } std::string GetServiceNameFieldName() { return "__ServiceName"; }
std::string GetMarshallerFieldName(const Descriptor* message) { std::string GetMarshallerFieldName(const Descriptor* message) {
@ -613,8 +628,8 @@ void GenerateBindServiceWithBinderMethod(Printer* out,
const ServiceDescriptor* service) { const ServiceDescriptor* service) {
out->Print( out->Print(
"/// <summary>Register service method with a service " "/// <summary>Register service method with a service "
"binder without implementation. Useful when customizing the service " "binder with or without implementation. Useful when customizing the "
"binding logic.\n" "service binding logic.\n"
"/// Note: this method is part of an experimental API that can change or " "/// Note: this method is part of an experimental API that can change or "
"be " "be "
"removed without any prior notice.</summary>\n"); "removed without any prior notice.</summary>\n");
@ -623,15 +638,26 @@ void GenerateBindServiceWithBinderMethod(Printer* out,
"calling <c>AddMethod</c> on this object." "calling <c>AddMethod</c> on this object."
"</param>\n"); "</param>\n");
out->Print( out->Print(
"public static void BindService(grpc::ServiceBinderBase " "/// <param name=\"serviceImpl\">An object implementing the server-side"
"serviceBinder)\n"); " handling logic.</param>\n");
out->Print(
"public static void BindService(grpc::ServiceBinderBase serviceBinder, "
"$implclass$ "
"serviceImpl)\n",
"implclass", GetServerClassName(service));
out->Print("{\n"); out->Print("{\n");
out->Indent(); out->Indent();
for (int i = 0; i < service->method_count(); i++) { for (int i = 0; i < service->method_count(); i++) {
const MethodDescriptor* method = service->method(i); const MethodDescriptor* method = service->method(i);
out->Print("serviceBinder.AddMethod($methodfield$);\n", "methodfield", out->Print(
GetMethodFieldName(method)); "serviceBinder.AddMethod($methodfield$, serviceImpl == null ? null : "
"new $servermethodtype$<$inputtype$, $outputtype$>("
"serviceImpl.$methodname$));\n",
"methodfield", GetMethodFieldName(method), "servermethodtype",
GetCSharpServerMethodType(GetMethodType(method)), "inputtype",
GetClassName(method->input_type()), "outputtype",
GetClassName(method->output_type()), "methodname", method->name());
} }
out->Outdent(); out->Outdent();

@ -35,13 +35,63 @@ namespace Grpc.Core
public class ServiceBinderBase public class ServiceBinderBase
{ {
/// <summary> /// <summary>
/// Adds a method without a handler. /// Adds a definition for a single request - single response method.
/// </summary> /// </summary>
/// <typeparam name="TRequest">The request message class.</typeparam> /// <typeparam name="TRequest">The request message class.</typeparam>
/// <typeparam name="TResponse">The response message class.</typeparam> /// <typeparam name="TResponse">The response message class.</typeparam>
/// <param name="method">The method.</param> /// <param name="method">The method.</param>
/// <param name="handler">The method handler.</param>
public virtual void AddMethod<TRequest, TResponse>( public virtual void AddMethod<TRequest, TResponse>(
Method<TRequest, TResponse> method) Method<TRequest, TResponse> method,
UnaryServerMethod<TRequest, TResponse> handler)
where TRequest : class
where TResponse : class
{
throw new NotImplementedException();
}
/// <summary>
/// Adds a definition for a client streaming method.
/// </summary>
/// <typeparam name="TRequest">The request message class.</typeparam>
/// <typeparam name="TResponse">The response message class.</typeparam>
/// <param name="method">The method.</param>
/// <param name="handler">The method handler.</param>
public virtual void AddMethod<TRequest, TResponse>(
Method<TRequest, TResponse> method,
ClientStreamingServerMethod<TRequest, TResponse> handler)
where TRequest : class
where TResponse : class
{
throw new NotImplementedException();
}
/// <summary>
/// Adds a definition for a server streaming method.
/// </summary>
/// <typeparam name="TRequest">The request message class.</typeparam>
/// <typeparam name="TResponse">The response message class.</typeparam>
/// <param name="method">The method.</param>
/// <param name="handler">The method handler.</param>
public virtual void AddMethod<TRequest, TResponse>(
Method<TRequest, TResponse> method,
ServerStreamingServerMethod<TRequest, TResponse> handler)
where TRequest : class
where TResponse : class
{
throw new NotImplementedException();
}
/// <summary>
/// Adds a definition for a bidirectional streaming method.
/// </summary>
/// <typeparam name="TRequest">The request message class.</typeparam>
/// <typeparam name="TResponse">The response message class.</typeparam>
/// <param name="method">The method.</param>
/// <param name="handler">The method handler.</param>
public virtual void AddMethod<TRequest, TResponse>(
Method<TRequest, TResponse> method,
DuplexStreamingServerMethod<TRequest, TResponse> handler)
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {

@ -287,15 +287,16 @@ namespace Math {
.AddMethod(__Method_Sum, serviceImpl.Sum).Build(); .AddMethod(__Method_Sum, serviceImpl.Sum).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, MathBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_Div); serviceBinder.AddMethod(__Method_Div, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Math.DivArgs, global::Math.DivReply>(serviceImpl.Div));
serviceBinder.AddMethod(__Method_DivMany); serviceBinder.AddMethod(__Method_DivMany, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Math.DivArgs, global::Math.DivReply>(serviceImpl.DivMany));
serviceBinder.AddMethod(__Method_Fib); serviceBinder.AddMethod(__Method_Fib, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Math.FibArgs, global::Math.Num>(serviceImpl.Fib));
serviceBinder.AddMethod(__Method_Sum); serviceBinder.AddMethod(__Method_Sum, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod<global::Math.Num, global::Math.Num>(serviceImpl.Sum));
} }
} }

@ -233,13 +233,14 @@ namespace Grpc.Health.V1 {
.AddMethod(__Method_Watch, serviceImpl.Watch).Build(); .AddMethod(__Method_Watch, serviceImpl.Watch).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, HealthBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_Check); serviceBinder.AddMethod(__Method_Check, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Health.V1.HealthCheckRequest, global::Grpc.Health.V1.HealthCheckResponse>(serviceImpl.Check));
serviceBinder.AddMethod(__Method_Watch); serviceBinder.AddMethod(__Method_Watch, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Grpc.Health.V1.HealthCheckRequest, global::Grpc.Health.V1.HealthCheckResponse>(serviceImpl.Watch));
} }
} }

@ -324,16 +324,17 @@ namespace Grpc.Testing {
.AddMethod(__Method_StreamingBothWays, serviceImpl.StreamingBothWays).Build(); .AddMethod(__Method_StreamingBothWays, serviceImpl.StreamingBothWays).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, BenchmarkServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_UnaryCall); serviceBinder.AddMethod(__Method_UnaryCall, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.UnaryCall));
serviceBinder.AddMethod(__Method_StreamingCall); serviceBinder.AddMethod(__Method_StreamingCall, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.StreamingCall));
serviceBinder.AddMethod(__Method_StreamingFromClient); serviceBinder.AddMethod(__Method_StreamingFromClient, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.StreamingFromClient));
serviceBinder.AddMethod(__Method_StreamingFromServer); serviceBinder.AddMethod(__Method_StreamingFromServer, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.StreamingFromServer));
serviceBinder.AddMethod(__Method_StreamingBothWays); serviceBinder.AddMethod(__Method_StreamingBothWays, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.StreamingBothWays));
} }
} }

@ -80,10 +80,11 @@ namespace Grpc.Testing {
return grpc::ServerServiceDefinition.CreateBuilder().Build(); return grpc::ServerServiceDefinition.CreateBuilder().Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, EmptyServiceBase serviceImpl)
{ {
} }

@ -193,13 +193,14 @@ namespace Grpc.Testing {
.AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build(); .AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, MetricsServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_GetAllGauges); serviceBinder.AddMethod(__Method_GetAllGauges, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse>(serviceImpl.GetAllGauges));
serviceBinder.AddMethod(__Method_GetGauge); serviceBinder.AddMethod(__Method_GetGauge, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse>(serviceImpl.GetGauge));
} }
} }

@ -143,12 +143,13 @@ namespace Grpc.Testing {
.AddMethod(__Method_ReportScenario, serviceImpl.ReportScenario).Build(); .AddMethod(__Method_ReportScenario, serviceImpl.ReportScenario).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, ReportQpsScenarioServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_ReportScenario); serviceBinder.AddMethod(__Method_ReportScenario, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.ScenarioResult, global::Grpc.Testing.Void>(serviceImpl.ReportScenario));
} }
} }

@ -539,19 +539,20 @@ namespace Grpc.Testing {
.AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall).Build(); .AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, TestServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_EmptyCall); serviceBinder.AddMethod(__Method_EmptyCall, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>(serviceImpl.EmptyCall));
serviceBinder.AddMethod(__Method_UnaryCall); serviceBinder.AddMethod(__Method_UnaryCall, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.UnaryCall));
serviceBinder.AddMethod(__Method_CacheableUnaryCall); serviceBinder.AddMethod(__Method_CacheableUnaryCall, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.SimpleRequest, global::Grpc.Testing.SimpleResponse>(serviceImpl.CacheableUnaryCall));
serviceBinder.AddMethod(__Method_StreamingOutputCall); serviceBinder.AddMethod(__Method_StreamingOutputCall, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>(serviceImpl.StreamingOutputCall));
serviceBinder.AddMethod(__Method_StreamingInputCall); serviceBinder.AddMethod(__Method_StreamingInputCall, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod<global::Grpc.Testing.StreamingInputCallRequest, global::Grpc.Testing.StreamingInputCallResponse>(serviceImpl.StreamingInputCall));
serviceBinder.AddMethod(__Method_FullDuplexCall); serviceBinder.AddMethod(__Method_FullDuplexCall, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>(serviceImpl.FullDuplexCall));
serviceBinder.AddMethod(__Method_HalfDuplexCall); serviceBinder.AddMethod(__Method_HalfDuplexCall, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Testing.StreamingOutputCallRequest, global::Grpc.Testing.StreamingOutputCallResponse>(serviceImpl.HalfDuplexCall));
serviceBinder.AddMethod(__Method_UnimplementedCall); serviceBinder.AddMethod(__Method_UnimplementedCall, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>(serviceImpl.UnimplementedCall));
} }
} }
@ -676,12 +677,13 @@ namespace Grpc.Testing {
.AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall).Build(); .AddMethod(__Method_UnimplementedCall, serviceImpl.UnimplementedCall).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, UnimplementedServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_UnimplementedCall); serviceBinder.AddMethod(__Method_UnimplementedCall, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>(serviceImpl.UnimplementedCall));
} }
} }
@ -802,13 +804,14 @@ namespace Grpc.Testing {
.AddMethod(__Method_Stop, serviceImpl.Stop).Build(); .AddMethod(__Method_Stop, serviceImpl.Stop).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, ReconnectServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_Start); serviceBinder.AddMethod(__Method_Start, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty>(serviceImpl.Start));
serviceBinder.AddMethod(__Method_Stop); serviceBinder.AddMethod(__Method_Stop, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo>(serviceImpl.Stop));
} }
} }

@ -321,15 +321,16 @@ namespace Grpc.Testing {
.AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker).Build(); .AddMethod(__Method_QuitWorker, serviceImpl.QuitWorker).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, WorkerServiceBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_RunServer); serviceBinder.AddMethod(__Method_RunServer, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Testing.ServerArgs, global::Grpc.Testing.ServerStatus>(serviceImpl.RunServer));
serviceBinder.AddMethod(__Method_RunClient); serviceBinder.AddMethod(__Method_RunClient, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Testing.ClientArgs, global::Grpc.Testing.ClientStatus>(serviceImpl.RunClient));
serviceBinder.AddMethod(__Method_CoreCount); serviceBinder.AddMethod(__Method_CoreCount, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.CoreRequest, global::Grpc.Testing.CoreResponse>(serviceImpl.CoreCount));
serviceBinder.AddMethod(__Method_QuitWorker); serviceBinder.AddMethod(__Method_QuitWorker, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Grpc.Testing.Void, global::Grpc.Testing.Void>(serviceImpl.QuitWorker));
} }
} }

@ -123,12 +123,13 @@ namespace Grpc.Reflection.V1Alpha {
.AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo).Build(); .AddMethod(__Method_ServerReflectionInfo, serviceImpl.ServerReflectionInfo).Build();
} }
/// <summary>Register service method with a service binder without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, ServerReflectionBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_ServerReflectionInfo); serviceBinder.AddMethod(__Method_ServerReflectionInfo, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod<global::Grpc.Reflection.V1Alpha.ServerReflectionRequest, global::Grpc.Reflection.V1Alpha.ServerReflectionResponse>(serviceImpl.ServerReflectionInfo));
} }
} }

Loading…
Cancel
Save