macula_rpc_server (macula v0.14.3)

View Source

RPC server managing registrations and calls. GenServer that integrates registry, cache, discovery, router, and executor.

Summary

Functions

Synchronous call to procedure.

Handle synchronous calls.

Handle asynchronous casts (none implemented).

Handle info messages (none expected).

Initialize server state.

List local registrations.

Stop RPC server.

Cleanup on termination.

Unregister procedure.

Types

config/0

-type config() ::
          #{routing_strategy => macula_rpc_router:strategy(),
            cache_enabled => boolean(),
            dht_lookup_fun => macula_rpc_dht:dht_lookup_fun(),
            send_fun => macula_rpc_executor:send_fun()}.

state/0

-type state() ::
          #{local_node_id := binary(),
            registry := macula_rpc_registry:registry(),
            cache := macula_rpc_cache:cache(),
            router_state := macula_rpc_router:router_state(),
            config := config()}.

Functions

call(Pid, Uri, Args, Timeout)

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

Synchronous call to procedure.

handle_call(_, From, State)

Handle synchronous calls.

handle_cast(Msg, State)

Handle asynchronous casts (none implemented).

handle_info(Info, State)

Handle info messages (none expected).

init(_)

Initialize server state.

list_registrations(Pid)

-spec list_registrations(pid()) -> [macula_rpc_registry:registration()].

List local registrations.

register(Pid, Uri, Handler, Metadata)

-spec register(pid(), binary(), macula_rpc_registry:handler_fn(), map()) -> ok.

Register procedure.

start_link(LocalNodeId, Config)

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

Start RPC server.

stop(Pid)

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

Stop RPC server.

terminate(Reason, State)

Cleanup on termination.

unregister(Pid, Uri, Handler)

-spec unregister(pid(), binary(), macula_rpc_registry:handler_fn()) -> ok.

Unregister procedure.