From b455bcc30101e41625753888626b17a5e48f6cdc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 22 Mar 2016 16:08:18 -0700 Subject: add host field support to CallInvoker --- src/compiler/csharp_generator.cc | 10 +++++----- src/csharp/Grpc.Core/CallInvoker.cs | 10 +++++----- src/csharp/Grpc.Core/ClientBase.cs | 10 +++++----- src/csharp/Grpc.Core/DefaultCallInvoker.cs | 29 ++++++++++++----------------- 4 files changed, 27 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index bc40880e5c..4a96a909de 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -388,7 +388,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { GetClassName(method->output_type())); out->Print("{\n"); out->Indent(); - out->Print("return CallInvoker.BlockingUnaryCall($methodfield$, options, request);\n", + out->Print("return CallInvoker.BlockingUnaryCall($methodfield$, null, options, request);\n", "methodfield", GetMethodFieldName(method)); out->Outdent(); out->Print("}\n"); @@ -422,20 +422,20 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { out->Indent(); switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: - out->Print("return CallInvoker.AsyncUnaryCall($methodfield$, options, request);\n", + out->Print("return CallInvoker.AsyncUnaryCall($methodfield$, null, options, request);\n", "methodfield", GetMethodFieldName(method)); break; case METHODTYPE_CLIENT_STREAMING: - out->Print("return CallInvoker.AsyncClientStreamingCall($methodfield$, options);\n", + out->Print("return CallInvoker.AsyncClientStreamingCall($methodfield$, null, options);\n", "methodfield", GetMethodFieldName(method)); break; case METHODTYPE_SERVER_STREAMING: out->Print( - "return CallInvoker.AsyncServerStreamingCall($methodfield$, options, request);\n", + "return CallInvoker.AsyncServerStreamingCall($methodfield$, null, options, request);\n", "methodfield", GetMethodFieldName(method)); break; case METHODTYPE_BIDI_STREAMING: - out->Print("return CallInvoker.AsyncDuplexStreamingCall($methodfield$, options);\n", + out->Print("return CallInvoker.AsyncDuplexStreamingCall($methodfield$, null, options);\n", "methodfield", GetMethodFieldName(method)); break; default: diff --git a/src/csharp/Grpc.Core/CallInvoker.cs b/src/csharp/Grpc.Core/CallInvoker.cs index e8e43968f8..cec5255692 100644 --- a/src/csharp/Grpc.Core/CallInvoker.cs +++ b/src/csharp/Grpc.Core/CallInvoker.cs @@ -45,14 +45,14 @@ namespace Grpc.Core /// /// Invokes a simple remote call in a blocking fashion. /// - public abstract TResponse BlockingUnaryCall(Method method, CallOptions options, TRequest request) + public abstract TResponse BlockingUnaryCall(Method method, string host, CallOptions options, TRequest request) where TRequest : class where TResponse : class; /// /// Invokes a simple remote call asynchronously. /// - public abstract AsyncUnaryCall AsyncUnaryCall(Method method, CallOptions options, TRequest request) + public abstract AsyncUnaryCall AsyncUnaryCall(Method method, string host, CallOptions options, TRequest request) where TRequest : class where TResponse : class; @@ -60,7 +60,7 @@ namespace Grpc.Core /// Invokes a server streaming call asynchronously. /// In server streaming scenario, client sends on request and server responds with a stream of responses. /// - public abstract AsyncServerStreamingCall AsyncServerStreamingCall(Method method, CallOptions options, TRequest request) + public abstract AsyncServerStreamingCall AsyncServerStreamingCall(Method method, string host, CallOptions options, TRequest request) where TRequest : class where TResponse : class; @@ -68,7 +68,7 @@ namespace Grpc.Core /// Invokes a client streaming call asynchronously. /// In client streaming scenario, client sends a stream of requests and server responds with a single response. /// - public abstract AsyncClientStreamingCall AsyncClientStreamingCall(Method method, CallOptions options) + public abstract AsyncClientStreamingCall AsyncClientStreamingCall(Method method, string host, CallOptions options) where TRequest : class where TResponse : class; @@ -77,7 +77,7 @@ namespace Grpc.Core /// In duplex streaming scenario, client sends a stream of requests and server responds with a stream of responses. /// The response stream is completely independent and both side can be sending messages at the same time. /// - public abstract AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, CallOptions options) + public abstract AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, string host, CallOptions options) where TRequest : class where TResponse : class; } diff --git a/src/csharp/Grpc.Core/ClientBase.cs b/src/csharp/Grpc.Core/ClientBase.cs index f5d6ae744f..9f3c4a5327 100644 --- a/src/csharp/Grpc.Core/ClientBase.cs +++ b/src/csharp/Grpc.Core/ClientBase.cs @@ -124,11 +124,11 @@ namespace Grpc.Core /// By default, this will be set to null with the meaning /// "use default host". /// - public string Host - { - get; - set; - } + //public string Host + //{ + // get; + // set; + //} /// /// Creates a new call to given method. diff --git a/src/csharp/Grpc.Core/DefaultCallInvoker.cs b/src/csharp/Grpc.Core/DefaultCallInvoker.cs index 8b77651c0c..5329478a15 100644 --- a/src/csharp/Grpc.Core/DefaultCallInvoker.cs +++ b/src/csharp/Grpc.Core/DefaultCallInvoker.cs @@ -56,18 +56,18 @@ namespace Grpc.Core /// /// Invokes a simple remote call in a blocking fashion. /// - public override TResponse BlockingUnaryCall(Method method, CallOptions options, TRequest request) + public override TResponse BlockingUnaryCall(Method method, string host, CallOptions options, TRequest request) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.BlockingUnaryCall(call, request); } /// /// Invokes a simple remote call asynchronously. /// - public override AsyncUnaryCall AsyncUnaryCall(Method method, CallOptions options, TRequest request) + public override AsyncUnaryCall AsyncUnaryCall(Method method, string host, CallOptions options, TRequest request) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncUnaryCall(call, request); } @@ -75,9 +75,9 @@ namespace Grpc.Core /// Invokes a server streaming call asynchronously. /// In server streaming scenario, client sends on request and server responds with a stream of responses. /// - public override AsyncServerStreamingCall AsyncServerStreamingCall(Method method, CallOptions options, TRequest request) + public override AsyncServerStreamingCall AsyncServerStreamingCall(Method method, string host, CallOptions options, TRequest request) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncServerStreamingCall(call, request); } @@ -85,9 +85,9 @@ namespace Grpc.Core /// Invokes a client streaming call asynchronously. /// In client streaming scenario, client sends a stream of requests and server responds with a single response. /// - public override AsyncClientStreamingCall AsyncClientStreamingCall(Method method, CallOptions options) + public override AsyncClientStreamingCall AsyncClientStreamingCall(Method method, string host, CallOptions options) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncClientStreamingCall(call); } @@ -96,22 +96,17 @@ namespace Grpc.Core /// In duplex streaming scenario, client sends a stream of requests and server responds with a stream of responses. /// The response stream is completely independent and both side can be sending messages at the same time. /// - public override AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, CallOptions options) + public override AsyncDuplexStreamingCall AsyncDuplexStreamingCall(Method method, string host, CallOptions options) { - var call = CreateCall(method, options); + var call = CreateCall(method, host, options); return Calls.AsyncDuplexStreamingCall(call); } - protected virtual string Host - { - get { return null; } - } - - protected virtual CallInvocationDetails CreateCall(Method method, CallOptions options) + protected virtual CallInvocationDetails CreateCall(Method method, string host, CallOptions options) where TRequest : class where TResponse : class { - return new CallInvocationDetails(channel, method, Host, options); + return new CallInvocationDetails(channel, method, host, options); } } } -- cgit v1.2.3