aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/python_generator.cc
diff options
context:
space:
mode:
authorGravatar Nathaniel Manista <nathaniel@google.com>2015-03-30 18:14:52 +0000
committerGravatar Nathaniel Manista <nathaniel@google.com>2015-03-30 18:14:52 +0000
commitf492b16d48b48ec45adb8dfce41d0756afeb3e96 (patch)
tree61855b39ba2fc135f074e9f3cd9a87c74ba785a4 /src/compiler/python_generator.cc
parent675de61e4ba46f6910eab9051ea77ee73cdf8c28 (diff)
Unify early_adopter construction functions
It was awkward for the generated code to call an API that offered both insecure_server and secure_server as well as insecure_stub and secure_stub. With this change there is just a single server function and a single stub function and security is decided based on arguments passed.
Diffstat (limited to 'src/compiler/python_generator.cc')
-rw-r--r--src/compiler/python_generator.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index 748417e477..d32213f7d5 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -271,7 +271,7 @@ bool GetModuleAndMessagePath(const Descriptor* type,
bool PrintServerFactory(const grpc::string& package_qualified_service_name,
const ServiceDescriptor* service, Printer* out) {
out->Print("def early_adopter_create_$Service$_server(servicer, port, "
- "root_certificates, key_chain_pairs):\n",
+ "private_key=None, certificate_chain=None):\n",
"Service", service->name());
{
IndentScope raii_create_server_indent(out);
@@ -339,10 +339,10 @@ bool PrintServerFactory(const grpc::string& package_qualified_service_name,
}
out->Print("}\n");
out->Print(
- "return implementations.secure_server("
+ "return implementations.server("
"\"$PackageQualifiedServiceName$\","
- " method_service_descriptions, port, root_certificates,"
- " key_chain_pairs)\n",
+ " method_service_descriptions, port, private_key=private_key,"
+ " certificate_chain=certificate_chain)\n",
"PackageQualifiedServiceName", package_qualified_service_name);
}
return true;
@@ -353,7 +353,9 @@ bool PrintStubFactory(const grpc::string& package_qualified_service_name,
map<grpc::string, grpc::string> dict = ListToDict({
"Service", service->name(),
});
- out->Print(dict, "def early_adopter_create_$Service$_stub(host, port):\n");
+ out->Print(dict, "def early_adopter_create_$Service$_stub(host, port,"
+ " secure=False, root_certificates=None, private_key=None,"
+ " certificate_chain=None, server_host_override=None):\n");
{
IndentScope raii_create_server_indent(out);
map<grpc::string, grpc::string> method_description_constructors;
@@ -419,9 +421,12 @@ bool PrintStubFactory(const grpc::string& package_qualified_service_name,
}
out->Print("}\n");
out->Print(
- "return implementations.insecure_stub("
+ "return implementations.stub("
"\"$PackageQualifiedServiceName$\","
- " method_invocation_descriptions, host, port)\n",
+ " method_invocation_descriptions, host, port, secure=secure,"
+ " root_certificates=root_certificates, private_key=private_key,"
+ " certificate_chain=certificate_chain,"
+ " server_host_override=server_host_override)\n",
"PackageQualifiedServiceName", package_qualified_service_name);
}
return true;