livery_grpc_codegen (livery_grpc v0.1.1)
View SourceGenerate Erlang stubs from a compiled gpb proto module.
Two kinds of module, per service, so a service reads as plain Erlang:
A client stub
<service>_client, giving anerpc-style call per RPC:greeter_client:say_hello(Conn, Request). Unary and server-streaming wraplivery_grpc_client:call/4, client-streaming wrapsclient_stream/4, and bidirectional wrapsopen/3(returning a stream handle to drive withsend/2,recv/1, ...).A behaviour
<service>_service, declaring one-callbackper RPC so a handler module can-behaviour(greeter_service)and have the compiler and dialyzer check it.
generate/2,3 writes the source to a directory; client_module/2 and
behaviour_module/2 return {Module, Source} for callers that compile in
memory. The generated client resolves the method descriptor at call time
via livery_grpc_service, so it stays correct if the proto is recompiled.
Summary
Functions
Return {Module, Source} for a service's callback behaviour module.
Return {Module, Source} for a service's client stub module.
generate/3 writing both the client and behaviour modules.
Write the chosen stub kinds for every service in Proto to OutDir.
Returns the list of written file paths.
Types
Functions
Return {Module, Source} for a service's callback behaviour module.
Return {Module, Source} for a service's client stub module.
-spec generate(module(), file:name_all()) -> {ok, [file:name_all()]} | {error, term()}.
generate/3 writing both the client and behaviour modules.
-spec generate(module(), file:name_all(), [kind()]) -> {ok, [file:name_all()]} | {error, term()}.
Write the chosen stub kinds for every service in Proto to OutDir.
Returns the list of written file paths.