Packages
Typed distributed messaging for Gleam on the BEAM.
Retired package: Deprecated - The project needs to be redesigned around a much smaller and clearer core.
Current section
Files
Jump to
Current section
Files
src/distribute@registry@behaviour.erl
-module(distribute@registry@behaviour).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/distribute/registry/behaviour.gleam").
-export([init/0, register/3, unregister/2, lookup/2, list_nodes/1]).
-export_type([metadata/0, registry_error/0, registry_state/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type metadata() :: {metadata,
binary(),
list(distribute@capability:capability()),
binary()}.
-type registry_error() :: not_found |
already_exists |
{invalid_argument, binary()} |
{adapter_failure, binary()}.
-type registry_state() :: registry_state.
-file("src/distribute/registry/behaviour.gleam", 74).
?DOC(
" Initialize a fresh registry state. Implementations may accept config\n"
" via environment or separate constructors; the core can call `init()` when\n"
" creating an adapter instance.\n"
).
-spec init() -> registry_state().
init() ->
registry_state.
-file("src/distribute/registry/behaviour.gleam", 80).
?DOC(
" Register a node with associated metadata.\n"
" Returns the updated state and `Ok(Nil)` on success or `Error(AdapterFailure(...))`.\n"
).
-spec register(registry_state(), binary(), metadata()) -> {registry_state(),
{ok, nil} | {error, registry_error()}}.
register(State, _, _) ->
{State, {error, {adapter_failure, <<"not implemented"/utf8>>}}}.
-file("src/distribute/registry/behaviour.gleam", 89).
?DOC(" Unregister a node.\n").
-spec unregister(registry_state(), binary()) -> {registry_state(),
{ok, nil} | {error, registry_error()}}.
unregister(State, _) ->
{State, {error, {adapter_failure, <<"not implemented"/utf8>>}}}.
-file("src/distribute/registry/behaviour.gleam", 97).
?DOC(" Lookup node metadata. Returns `Some(metadata)` if present or `None`.\n").
-spec lookup(registry_state(), binary()) -> {registry_state(),
gleam@option:option(metadata())}.
lookup(State, _) ->
{State, none}.
-file("src/distribute/registry/behaviour.gleam", 105).
?DOC(" Return the list of known node ids.\n").
-spec list_nodes(registry_state()) -> {registry_state(), list(binary())}.
list_nodes(State) ->
{State, []}.