Search documentation of macula

# macula_gateway_rpc (macula v0.44.2)

View Source

RPC Handler GenServer - manages RPC handler registration and call routing.

Responsibilities: - Register/unregister RPC handlers for procedures - Route RPC calls to registered handlers - Handle call/response matching - Monitor handler processes for automatic cleanup

Extracted from macula_gateway.erl (Phase 4)

# Summary

## Functions

call(Pid, Procedure, Args, Opts)

Make an RPC call to a procedure.

get_handler(Pid, Procedure)

Get the handler for a procedure.

handle_call(Request, From, State)
handle_cast(Msg, State)
handle_info(Info, State)

Handle handler process death - automatic cleanup.

init(Opts)
invoke_handler(Pid, Procedure, Args)

Invoke a handler directly for local calls. If handler is a function, invokes it directly. If handler is a PID, sends rpc_call message and waits for response.

list_handlers(Pid)

List all registered handlers.

register_handler(Pid, Procedure, Handler)

Register a handler for an RPC procedure. Handler can be either a PID or a function.

start_link(Opts)

Start the RPC handler with options.

stop(Pid)

Stop the RPC handler.

terminate(Reason, State)
unregister_handler(Pid, Procedure)

Unregister a handler for an RPC procedure.

# Functions

# call(Pid, Procedure, Args, Opts)

    -spec call(pid(), binary(), map(), map()) -> {ok, term()} | {error, term()}.

Make an RPC call to a procedure.

# get_handler(Pid, Procedure)

    -spec get_handler(pid(), binary()) -> {ok, pid()} | not_found.

Get the handler for a procedure.

# handle_call(Request, From, State)

# handle_cast(Msg, State)

# handle_info(Info, State)

Handle handler process death - automatic cleanup.

# init(Opts)

# invoke_handler(Pid, Procedure, Args)

    -spec invoke_handler(pid(), binary(), map()) -> {ok, term()} | {error, term()}.

Invoke a handler directly for local calls. If handler is a function, invokes it directly. If handler is a PID, sends rpc_call message and waits for response.

# list_handlers(Pid)

    -spec list_handlers(pid()) -> {ok, [{binary(), pid()}]}.

List all registered handlers.

# register_handler(Pid, Procedure, Handler)

    -spec register_handler(pid(), binary(), pid() | fun()) -> ok.

Register a handler for an RPC procedure. Handler can be either a PID or a function.

# start_link(Opts)

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

Start the RPC handler with options.

# stop(Pid)

    -spec stop(pid()) -> ok.

Stop the RPC handler.

# terminate(Reason, State)

# unregister_handler(Pid, Procedure)

    -spec unregister_handler(pid(), binary()) -> ok.

Unregister a handler for an RPC procedure.