Skip to content
Snippets Groups Projects
Commit b455bcc3 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

add host field support to CallInvoker

parent 809148d6
No related branches found
No related tags found
No related merge requests found
...@@ -388,7 +388,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { ...@@ -388,7 +388,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
GetClassName(method->output_type())); GetClassName(method->output_type()));
out->Print("{\n"); out->Print("{\n");
out->Indent(); out->Indent();
out->Print("return CallInvoker.BlockingUnaryCall($methodfield$, options, request);\n", out->Print("return CallInvoker.BlockingUnaryCall($methodfield$, null, options, request);\n",
"methodfield", GetMethodFieldName(method)); "methodfield", GetMethodFieldName(method));
out->Outdent(); out->Outdent();
out->Print("}\n"); out->Print("}\n");
...@@ -422,20 +422,20 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { ...@@ -422,20 +422,20 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
out->Indent(); out->Indent();
switch (GetMethodType(method)) { switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING: 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)); "methodfield", GetMethodFieldName(method));
break; break;
case METHODTYPE_CLIENT_STREAMING: case METHODTYPE_CLIENT_STREAMING:
out->Print("return CallInvoker.AsyncClientStreamingCall($methodfield$, options);\n", out->Print("return CallInvoker.AsyncClientStreamingCall($methodfield$, null, options);\n",
"methodfield", GetMethodFieldName(method)); "methodfield", GetMethodFieldName(method));
break; break;
case METHODTYPE_SERVER_STREAMING: case METHODTYPE_SERVER_STREAMING:
out->Print( out->Print(
"return CallInvoker.AsyncServerStreamingCall($methodfield$, options, request);\n", "return CallInvoker.AsyncServerStreamingCall($methodfield$, null, options, request);\n",
"methodfield", GetMethodFieldName(method)); "methodfield", GetMethodFieldName(method));
break; break;
case METHODTYPE_BIDI_STREAMING: case METHODTYPE_BIDI_STREAMING:
out->Print("return CallInvoker.AsyncDuplexStreamingCall($methodfield$, options);\n", out->Print("return CallInvoker.AsyncDuplexStreamingCall($methodfield$, null, options);\n",
"methodfield", GetMethodFieldName(method)); "methodfield", GetMethodFieldName(method));
break; break;
default: default:
......
...@@ -45,14 +45,14 @@ namespace Grpc.Core ...@@ -45,14 +45,14 @@ namespace Grpc.Core
/// <summary> /// <summary>
/// Invokes a simple remote call in a blocking fashion. /// Invokes a simple remote call in a blocking fashion.
/// </summary> /// </summary>
public abstract TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) public abstract TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
where TRequest : class where TRequest : class
where TResponse : class; where TResponse : class;
/// <summary> /// <summary>
/// Invokes a simple remote call asynchronously. /// Invokes a simple remote call asynchronously.
/// </summary> /// </summary>
public abstract AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) public abstract AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
where TRequest : class where TRequest : class
where TResponse : class; where TResponse : class;
...@@ -60,7 +60,7 @@ namespace Grpc.Core ...@@ -60,7 +60,7 @@ namespace Grpc.Core
/// Invokes a server streaming call asynchronously. /// Invokes a server streaming call asynchronously.
/// In server streaming scenario, client sends on request and server responds with a stream of responses. /// In server streaming scenario, client sends on request and server responds with a stream of responses.
/// </summary> /// </summary>
public abstract AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) public abstract AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
where TRequest : class where TRequest : class
where TResponse : class; where TResponse : class;
...@@ -68,7 +68,7 @@ namespace Grpc.Core ...@@ -68,7 +68,7 @@ namespace Grpc.Core
/// Invokes a client streaming call asynchronously. /// Invokes a client streaming call asynchronously.
/// In client streaming scenario, client sends a stream of requests and server responds with a single response. /// In client streaming scenario, client sends a stream of requests and server responds with a single response.
/// </summary> /// </summary>
public abstract AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) public abstract AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
where TRequest : class where TRequest : class
where TResponse : class; where TResponse : class;
...@@ -77,7 +77,7 @@ namespace Grpc.Core ...@@ -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. /// 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. /// The response stream is completely independent and both side can be sending messages at the same time.
/// </summary> /// </summary>
public abstract AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) public abstract AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
where TRequest : class where TRequest : class
where TResponse : class; where TResponse : class;
} }
......
...@@ -124,11 +124,11 @@ namespace Grpc.Core ...@@ -124,11 +124,11 @@ namespace Grpc.Core
/// By default, this will be set to <c>null</c> with the meaning /// By default, this will be set to <c>null</c> with the meaning
/// "use default host". /// "use default host".
/// </summary> /// </summary>
public string Host //public string Host
{ //{
get; // get;
set; // set;
} //}
/// <summary> /// <summary>
/// Creates a new call to given method. /// Creates a new call to given method.
......
...@@ -56,18 +56,18 @@ namespace Grpc.Core ...@@ -56,18 +56,18 @@ namespace Grpc.Core
/// <summary> /// <summary>
/// Invokes a simple remote call in a blocking fashion. /// Invokes a simple remote call in a blocking fashion.
/// </summary> /// </summary>
public override TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) public override TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
{ {
var call = CreateCall(method, options); var call = CreateCall(method, host, options);
return Calls.BlockingUnaryCall(call, request); return Calls.BlockingUnaryCall(call, request);
} }
/// <summary> /// <summary>
/// Invokes a simple remote call asynchronously. /// Invokes a simple remote call asynchronously.
/// </summary> /// </summary>
public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) public override AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
{ {
var call = CreateCall(method, options); var call = CreateCall(method, host, options);
return Calls.AsyncUnaryCall(call, request); return Calls.AsyncUnaryCall(call, request);
} }
...@@ -75,9 +75,9 @@ namespace Grpc.Core ...@@ -75,9 +75,9 @@ namespace Grpc.Core
/// Invokes a server streaming call asynchronously. /// Invokes a server streaming call asynchronously.
/// In server streaming scenario, client sends on request and server responds with a stream of responses. /// In server streaming scenario, client sends on request and server responds with a stream of responses.
/// </summary> /// </summary>
public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options, TRequest request) public override AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
{ {
var call = CreateCall(method, options); var call = CreateCall(method, host, options);
return Calls.AsyncServerStreamingCall(call, request); return Calls.AsyncServerStreamingCall(call, request);
} }
...@@ -85,9 +85,9 @@ namespace Grpc.Core ...@@ -85,9 +85,9 @@ namespace Grpc.Core
/// Invokes a client streaming call asynchronously. /// Invokes a client streaming call asynchronously.
/// In client streaming scenario, client sends a stream of requests and server responds with a single response. /// In client streaming scenario, client sends a stream of requests and server responds with a single response.
/// </summary> /// </summary>
public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) public override AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
{ {
var call = CreateCall(method, options); var call = CreateCall(method, host, options);
return Calls.AsyncClientStreamingCall(call); return Calls.AsyncClientStreamingCall(call);
} }
...@@ -96,22 +96,17 @@ namespace Grpc.Core ...@@ -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. /// 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. /// The response stream is completely independent and both side can be sending messages at the same time.
/// </summary> /// </summary>
public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options) public override AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
{ {
var call = CreateCall(method, options); var call = CreateCall(method, host, options);
return Calls.AsyncDuplexStreamingCall(call); return Calls.AsyncDuplexStreamingCall(call);
} }
protected virtual string Host protected virtual CallInvocationDetails<TRequest, TResponse> CreateCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
{
get { return null; }
}
protected virtual CallInvocationDetails<TRequest, TResponse> CreateCall<TRequest, TResponse>(Method<TRequest, TResponse> method, CallOptions options)
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
return new CallInvocationDetails<TRequest, TResponse>(channel, method, Host, options); return new CallInvocationDetails<TRequest, TResponse>(channel, method, host, options);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment