From 5324dfc54172777797e61f02548611826f9ac4fd Mon Sep 17 00:00:00 2001 From: Wojtek Czekalski Date: Wed, 13 Nov 2024 20:34:14 +0100 Subject: [PATCH] Fix arpaca codegen --- lib/eio/arpaca/bin/codegen.ml | 70 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/eio/arpaca/bin/codegen.ml b/lib/eio/arpaca/bin/codegen.ml index 14e9bd3..3d7e790 100644 --- a/lib/eio/arpaca/bin/codegen.ml +++ b/lib/eio/arpaca/bin/codegen.ml @@ -53,7 +53,7 @@ let to_snake_case = in fun str -> regex str -let service_name_of_package path = String.concat "." path +let service_name_of_package service_packages service = String.concat "." (service_packages @ [service]) let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit = @@ -74,7 +74,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit connection_error ) Grpc_client_eio.Io.t) request = let response = - Grpc_client_eio.Client.Unary.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Unary.call ~sw ~io ~service:"%s" ~method_name:%S ~headers:(Grpc_client.make_request_headers `Proto) (%s.%s request) @@ -89,8 +89,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit } | #Grpc_client_eio.Rpc_error.Unary.error' as rest -> Io'.raise_client_error (Unary rest)|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -99,13 +99,13 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit {|let %s (type headers net_response stream_error connection_error) ~sw ~(io : ( headers, net_response, - Pbrt.Encoder.t -> unit, + Pbrt.Encoder.t ->unit, Pbrt.Decoder.t Grpc_eio_core.Body_reader.consumer, stream_error, connection_error ) Grpc_client_eio.Io.t) request handler = let stream = - Grpc_client_eio.Client.Server_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Server_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (%s.%s request) (fun net_response ~read -> @@ -125,8 +125,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit | #Grpc_client_eio.Rpc_error.Server_streaming.error' as rest -> Io'.raise_client_error (Server_streaming rest) |} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -141,7 +141,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit connection_error ) Grpc_client_eio.Io.t) handler = let response = - Grpc_client_eio.Client.Client_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Client_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (fun net_response ~writer -> @@ -159,8 +159,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit } | #Grpc_client_eio.Rpc_error.Client_streaming.error' as rest -> Io'.raise_client_error (Client_streaming rest)|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -175,7 +175,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit connection_error ) Grpc_client_eio.Io.t) handler = let stream = - Grpc_client_eio.Client.Bidirectional_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Bidirectional_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (fun net_response ~writer ~read -> @@ -194,8 +194,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit | `Stream_result_success result -> result | #Grpc_client_eio.Rpc_error.Bidirectional_streaming.error' as rest -> Io'.raise_client_error (Bidirectional_streaming rest)|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -208,7 +208,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit F.linep sc {|let %s ~sw ~io request = let response = - Grpc_client_eio.Client.Unary.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Unary.call ~sw ~io ~service:"%s" ~method_name:%S ~headers:(Grpc_client.make_request_headers `Proto) (%s.%s request) @@ -223,8 +223,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit } | #Grpc_client_eio.Rpc_error.Unary.error' as rest -> Error rest|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -232,7 +232,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit F.linep sc {|let %s ~sw ~io request handler = let stream = - Grpc_client_eio.Client.Server_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Server_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (%s.%s request) (fun net_response ~read -> @@ -249,8 +249,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit | `Stream_result_success result -> Ok result | #Grpc_client_eio.Rpc_error.Server_streaming.error' as rest -> Error rest|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -258,7 +258,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit F.linep sc {|let %s ~sw ~io handler = let response = - Grpc_client_eio.Client.Client_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Client_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (fun net_response ~writer -> @@ -276,8 +276,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit } | #Grpc_client_eio.Rpc_error.Client_streaming.error' as rest -> Error rest|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -285,7 +285,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit F.linep sc {|let %s ~sw ~io handler = let stream = - Grpc_client_eio.Client.Bidirectional_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Bidirectional_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (fun net_response ~writer ~read -> @@ -303,8 +303,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit | `Stream_result_success result -> Ok result | #Grpc_client_eio.Rpc_error.Bidirectional_streaming.error' as rest -> Error rest|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -341,7 +341,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit | `Server_streaming -> F.linep sc {|let %s ~sw ~io request handler = - Grpc_client_eio.Client.Server_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Server_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (%s.%s request) (fun net_response ~read -> @@ -354,8 +354,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit in handler net_response responses)|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -363,7 +363,7 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit F.linep sc {|let %s ~sw ~io handler = let response = - Grpc_client_eio.Client.Client_streaming.call ~sw ~io ~service:"%s.%s" + Grpc_client_eio.Client.Client_streaming.call ~sw ~io ~service:"%s" ~method_name:"%s" ~headers:(Grpc_client.make_request_headers `Proto) (fun net_response ~writer -> @@ -382,8 +382,8 @@ let gen_service_client_struct ~proto_gen_module (service : Ot.service) sc : unit | #Grpc_client_eio.Rpc_error.Client_streaming.error' as rest -> rest|} (Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case) - (service_name_of_package service.service_packages) - service.service_name rpc.rpc_name typ_mod_name + (service_name_of_package service.service_packages service.service_name ) + rpc.rpc_name typ_mod_name (function_name_encode_pb ~service_name ~rpc_name rpc.rpc_req) typ_mod_name (function_name_decode_pb ~service_name ~rpc_name rpc.rpc_res) @@ -471,9 +471,9 @@ let gen_service_server_struct ~proto_gen_module (service : Ot.service) top_scope let rpc_name = rpc.rpc_name in let service_name = service.service_name in - F.linep sc {|| "%s.%s", %S ->|} - (String.concat "." service.service_packages) - service.service_name rpc.rpc_name; + F.linep sc {|| "%s", %S ->|} + (String.concat "." service.service_packages @ [service.service_name]) + rpc.rpc_name; let impl = Pb_codegen_util.function_name_of_rpc rpc |> to_snake_case in let decoder_func =