macula_rpc_registry (macula v0.20.5)
View SourceLocal 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
-type invocation_strategy() :: round_robin | random | local_first.
-type registration() :: #{uri := binary(), handler := handler_fn(), metadata := map()}.
-type registry() :: #{registrations := [registration()], strategy := invocation_strategy()}.
Functions
-spec find(registry(), binary()) -> [registration()].
Find all registrations for a URI.
-spec find_handlers(registry(), binary()) -> {ok, [registration()]} | not_found.
Find all handlers for a URI.
-spec list_registrations(registry()) -> [registration()].
List all registrations.
List all unique URIs in registry.
-spec new() -> registry().
Create new empty registry with default strategy (round_robin).
-spec new(invocation_strategy()) -> registry().
Create new empty registry with custom strategy.
-spec register(registry(), binary(), handler_fn(), map()) -> registry().
Register a procedure handler. Allows multiple handlers for the same URI (for load balancing).
-spec size(registry()) -> non_neg_integer().
Get total number of registrations.
-spec unregister(registry(), binary(), handler_fn()) -> registry().
Unregister a specific procedure handler. Only removes the exact handler function.