aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/cpp_generator.cc8
-rw-r--r--src/compiler/csharp_generator.cc82
2 files changed, 75 insertions, 15 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 75659947df..ea487bcd89 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -119,6 +119,7 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
"#include <grpc++/async_unary_call.h>\n"
"#include <grpc++/status.h>\n"
"#include <grpc++/stream.h>\n"
+ "#include <grpc++/stub_options.h>\n"
"\n"
"namespace grpc {\n"
"class CompletionQueue;\n"
@@ -574,8 +575,8 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Print("};\n");
printer->Print(
"static std::unique_ptr<Stub> NewStub(const std::shared_ptr< "
- "::grpc::ChannelInterface>& "
- "channel);\n");
+ "::grpc::ChannelInterface>& channel, "
+ "const ::grpc::StubOptions& options = ::grpc::StubOptions());\n");
printer->Print("\n");
@@ -966,7 +967,8 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
printer->Print(
*vars,
"std::unique_ptr< $ns$$Service$::Stub> $ns$$Service$::NewStub("
- "const std::shared_ptr< ::grpc::ChannelInterface>& channel) {\n"
+ "const std::shared_ptr< ::grpc::ChannelInterface>& channel, "
+ "const ::grpc::StubOptions& options) {\n"
" std::unique_ptr< $ns$$Service$::Stub> stub(new "
"$ns$$Service$::Stub(channel));\n"
" return stub;\n"
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index e0c1bcda19..9432bdda96 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -246,6 +246,8 @@ void GenerateStaticMethodField(Printer* out, const MethodDescriptor *method) {
out->Indent();
out->Print("$methodtype$,\n", "methodtype",
GetCSharpMethodType(GetMethodType(method)));
+ out->Print("$servicenamefield$,\n", "servicenamefield",
+ GetServiceNameFieldName());
out->Print("\"$methodname$\",\n", "methodname", method->name());
out->Print("$requestmarshaller$,\n", "requestmarshaller",
GetMarshallerFieldName(method->input_type()));
@@ -273,6 +275,13 @@ void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
"methodname", method->name(), "request",
GetClassName(method->input_type()), "response",
GetClassName(method->output_type()));
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "$response$ $methodname$($request$ request, CallOptions options);\n",
+ "methodname", method->name(), "request",
+ GetClassName(method->input_type()), "response",
+ GetClassName(method->output_type()));
}
std::string method_name = method->name();
@@ -284,6 +293,13 @@ void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
"methodname", method_name, "request_maybe",
GetMethodRequestParamMaybe(method), "returntype",
GetMethodReturnTypeClient(method));
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "$returntype$ $methodname$($request_maybe$CallOptions options);\n",
+ "methodname", method_name, "request_maybe",
+ GetMethodRequestParamMaybe(method), "returntype",
+ GetMethodReturnTypeClient(method));
}
out->Outdent();
out->Print("}\n");
@@ -340,10 +356,23 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
GetClassName(method->output_type()));
out->Print("{\n");
out->Indent();
- out->Print("var call = CreateCall($servicenamefield$, $methodfield$, headers, deadline);\n",
- "servicenamefield", GetServiceNameFieldName(), "methodfield",
- GetMethodFieldName(method));
- out->Print("return Calls.BlockingUnaryCall(call, request, cancellationToken);\n");
+ out->Print("var call = CreateCall($methodfield$, new CallOptions(headers, deadline, cancellationToken));\n",
+ "methodfield", GetMethodFieldName(method));
+ out->Print("return Calls.BlockingUnaryCall(call, request);\n");
+ out->Outdent();
+ out->Print("}\n");
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "public $response$ $methodname$($request$ request, CallOptions options)\n",
+ "methodname", method->name(), "request",
+ GetClassName(method->input_type()), "response",
+ GetClassName(method->output_type()));
+ out->Print("{\n");
+ out->Indent();
+ out->Print("var call = CreateCall($methodfield$, options);\n",
+ "methodfield", GetMethodFieldName(method));
+ out->Print("return Calls.BlockingUnaryCall(call, request);\n");
out->Outdent();
out->Print("}\n");
}
@@ -359,26 +388,55 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
GetMethodReturnTypeClient(method));
out->Print("{\n");
out->Indent();
- out->Print("var call = CreateCall($servicenamefield$, $methodfield$, headers, deadline);\n",
- "servicenamefield", GetServiceNameFieldName(), "methodfield",
- GetMethodFieldName(method));
+ out->Print("var call = CreateCall($methodfield$, new CallOptions(headers, deadline, cancellationToken));\n",
+ "methodfield", GetMethodFieldName(method));
switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING:
- out->Print("return Calls.AsyncUnaryCall(call, request, cancellationToken);\n");
+ out->Print("return Calls.AsyncUnaryCall(call, request);\n");
break;
case METHODTYPE_CLIENT_STREAMING:
- out->Print("return Calls.AsyncClientStreamingCall(call, cancellationToken);\n");
+ out->Print("return Calls.AsyncClientStreamingCall(call);\n");
break;
case METHODTYPE_SERVER_STREAMING:
out->Print(
- "return Calls.AsyncServerStreamingCall(call, request, cancellationToken);\n");
+ "return Calls.AsyncServerStreamingCall(call, request);\n");
break;
case METHODTYPE_BIDI_STREAMING:
- out->Print("return Calls.AsyncDuplexStreamingCall(call, cancellationToken);\n");
+ out->Print("return Calls.AsyncDuplexStreamingCall(call);\n");
break;
default:
GOOGLE_LOG(FATAL)<< "Can't get here.";
- }
+ }
+ out->Outdent();
+ out->Print("}\n");
+
+ // overload taking CallOptions as a param
+ out->Print(
+ "public $returntype$ $methodname$($request_maybe$CallOptions options)\n",
+ "methodname", method_name, "request_maybe",
+ GetMethodRequestParamMaybe(method), "returntype",
+ GetMethodReturnTypeClient(method));
+ out->Print("{\n");
+ out->Indent();
+ out->Print("var call = CreateCall($methodfield$, options);\n",
+ "methodfield", GetMethodFieldName(method));
+ switch (GetMethodType(method)) {
+ case METHODTYPE_NO_STREAMING:
+ out->Print("return Calls.AsyncUnaryCall(call, request);\n");
+ break;
+ case METHODTYPE_CLIENT_STREAMING:
+ out->Print("return Calls.AsyncClientStreamingCall(call);\n");
+ break;
+ case METHODTYPE_SERVER_STREAMING:
+ out->Print(
+ "return Calls.AsyncServerStreamingCall(call, request);\n");
+ break;
+ case METHODTYPE_BIDI_STREAMING:
+ out->Print("return Calls.AsyncDuplexStreamingCall(call);\n");
+ break;
+ default:
+ GOOGLE_LOG(FATAL)<< "Can't get here.";
+ }
out->Outdent();
out->Print("}\n");
}