Search documentation of macula

# macula_rpc_registry (macula v0.44.2)

View Source

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

# Summary

## Types

handler_fn/0
invocation_strategy/0
registration/0
registry/0

## Functions

find(_, Uri)

Find all registrations for a URI.

find_handlers(_, Uri)

Find all handlers for a URI.

list_registrations(_)

List all registrations.

list_uris(_)

List all unique URIs in registry.

new()

Create new empty registry with default strategy (round_robin).

new(Strategy)

Create new empty registry with custom strategy.

register(Registry, Uri, Handler, Metadata)

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

size(_)

Get total number of registrations.

unregister(Registry, Uri, Handler)

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.