livery_grpc_listener (livery_grpc v0.1.1)

View Source

Owns a gRPC h2 listener, supervised under livery_grpc_server_sup.

The h2 listen socket is owned by whichever process calls h2:start_server, so it must be a long-lived one or the socket closes with it. This gen_server is that owner: it opens the listener in init and holds it for the lifetime of the supervised child, so a server started from a transient caller (a test's init_per_suite, a short request) keeps running.

Summary

Types

start_opts()

-type start_opts() :: #{h2_opts := map()}.

Functions

code_change(Old, State, Extra)

-spec code_change(term(), map(), term()) -> {ok, map()}.

handle_call/3

-spec handle_call(term(), {pid(), term()}, map()) -> {reply, term(), map()}.

handle_cast(Msg, State)

-spec handle_cast(term(), map()) -> {noreply, map()}.

handle_info(Info, State)

-spec handle_info(term(), map()) -> {noreply, map()}.

init/1

-spec init(start_opts()) -> {ok, map()} | {stop, term()}.

listener(Pid)

-spec listener(pid()) -> livery_h2:listener().

The underlying h2 listener handle.

port(Pid)

-spec port(pid()) -> inet:port_number().

The TCP port the listener is bound to.

start_link(StartOpts)

-spec start_link(start_opts()) -> {ok, pid()} | {error, term()}.

terminate/2

-spec terminate(term(), map()) -> ok.