From adf6c611526ddf52c919095e559d88096e978adc Mon Sep 17 00:00:00 2001 From: ericcao Date: Tue, 29 Sep 2020 17:10:28 +0800 Subject: [PATCH] fix grpc protocol package name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Service-Name → ?( {proto package name} "." ) {service name} see https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md --- src/grpc_client_stream.erl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/grpc_client_stream.erl b/src/grpc_client_stream.erl index fea73f3..0c73d7f 100644 --- a/src/grpc_client_stream.erl +++ b/src/grpc_client_stream.erl @@ -228,11 +228,12 @@ new_stream(Connection, Service, Rpc, Encoder, Options) -> TransportOptions = proplists:get_value(http2_options, Options, []), {ok, StreamId} = grpc_client_connection:new_stream(Connection, TransportOptions), RpcDef = Encoder:find_rpc_def(Service, Rpc), + Package = Encoder:get_package_name(), %% the gpb rpc def has 'input', 'output' etc. %% All the information is combined in 1 map, %% which is is the state of the gen_server. RpcDef#{stream_id => StreamId, - package => [], + package => Package, service => Service, rpc => Rpc, queue => queue:new(), @@ -289,8 +290,11 @@ default_headers(#{service := Service, connection := #{host := Host, scheme := Scheme} }) -> - Path = iolist_to_binary(["/", Package, atom_to_list(Service), - "/", atom_to_list(Rpc)]), + ServiceFullName = case Package of + undefined -> atom_to_list(Service); + _ -> [atom_to_list(Package), ".", atom_to_list(Service)] + end, + Path = iolist_to_binary(["/", ServiceFullName, "/", atom_to_list(Rpc)]), Headers1 = case Compression of none -> [];