macula_rpc_registry (macula v0.20.5)

View Source

Local RPC procedure registration registry. Maps URIs to handler functions. Supports multiple handlers per URI (for load balancing).

Summary

Functions

Find all registrations for a URI.

Find all handlers for a URI.

List all registrations.

List all unique URIs in registry.

Create new empty registry with default strategy (round_robin).

Create new empty registry with custom strategy.

Register a procedure handler. Allows multiple handlers for the same URI (for load balancing).

Get total number of registrations.

Unregister a specific procedure handler. Only removes the exact handler function.

Types

handler_fn/0

-type handler_fn() :: fun((map()) -> {ok, term()} | {error, term()}).

invocation_strategy/0

-type invocation_strategy() :: round_robin | random | local_first.

registration/0

-type registration() :: #{uri := binary(), handler := handler_fn(), metadata := map()}.

registry/0

-type registry() :: #{registrations := [registration()], strategy := invocation_strategy()}.

Functions

find(_, Uri)

-spec find(registry(), binary()) -> [registration()].

Find all registrations for a URI.

find_handlers(_, Uri)

-spec find_handlers(registry(), binary()) -> {ok, [registration()]} | not_found.

Find all handlers for a URI.

list_registrations(_)

-spec list_registrations(registry()) -> [registration()].

List all registrations.

list_uris(_)

-spec list_uris(registry()) -> [binary()].

List all unique URIs in registry.

new()

-spec new() -> registry().

Create new empty registry with default strategy (round_robin).

new(Strategy)

-spec new(invocation_strategy()) -> registry().

Create new empty registry with custom strategy.

register(Registry, Uri, Handler, Metadata)

-spec register(registry(), binary(), handler_fn(), map()) -> registry().

Register a procedure handler. Allows multiple handlers for the same URI (for load balancing).

size(_)

-spec size(registry()) -> non_neg_integer().

Get total number of registrations.

unregister(Registry, Uri, Handler)

-spec unregister(registry(), binary(), handler_fn()) -> registry().

Unregister a specific procedure handler. Only removes the exact handler function.