@@ -2,8 +2,6 @@ function service_cb(io, t::CodeGenerators.ServiceType, ctx::CodeGenerators.Conte
22 namespace = join (ctx. proto_file. preamble. namespace, " ." )
33 service_name = t. name
44
5- export_names = Vector {String} ()
6-
75 for (i, rpc) in enumerate (t. rpcs)
86 rpc_path = " /$namespace .$service_name /$(rpc. name) "
97
@@ -18,7 +16,6 @@ function service_cb(io, t::CodeGenerators.ServiceType, ctx::CodeGenerators.Conte
1816 end
1917
2018 export_name = " $(service_name) _$(rpc. name) _Client"
21- push! (export_names, export_name)
2219
2320 println (io, " $(export_name) (" )
2421 println (io, " \t host, port;" )
@@ -39,16 +36,26 @@ function service_cb(io, t::CodeGenerators.ServiceType, ctx::CodeGenerators.Conte
3936 println (io, " \t keepalive=keepalive," )
4037 println (io, " \t max_send_message_length=max_send_message_length," )
4138 println (io, " \t max_recieve_message_length=max_recieve_message_length," )
42- println (io, " )\n " )
43- end
39+ println (io, " )" )
40+
41+ # TODO : define a standard way to check whether we should export that is used in both ProtoBuf.jl and gRPCClient.jl
42+ if CodeGenerators. is_namespaced (ctx. proto_file) || ctx. options. always_use_modules
43+ println (io, " export $(export_name) " )
44+ else
45+ println (io, " " )
46+ end
4447
45- # TODO : define a standard way to check whether we should export that is used in both ProtoBuf.jl and gRPCClient.jl
46- if ! isempty (export_names) && (CodeGenerators . is_namespaced (ctx . proto_file) || ctx . options . always_use_modules )
47- map (x -> println (io, " export $x " ), export_names)
48+ if i < lastindex (t . rpcs)
49+ println (io, " " )
50+ end
4851 end
52+
4953end
5054
51- import_cb (io, ctx) = println (io, " import gRPCClient" )
55+ import_cb (io, ctx, definitions) =
56+ mapreduce (x-> x isa CodeGenerators. ServiceType ? 1 : 0 , + , values (definitions)) > 0 &&
57+ println (io, " import gRPCClient" )
58+
5259
5360grpc_register_service_codegen () = CodeGenerators. register_external_codegen_handler (
5461 " gRPCClient.jl" ;
0 commit comments