distribute/registry/behaviour
Types
Minimal metadata the registry stores per-node.
pub type Metadata {
Metadata(
node_id: String,
capabilities: List(capability.Capability),
extra: String,
)
}
Constructors
-
Metadata( node_id: String, capabilities: List(capability.Capability), extra: String, )
Node identifier used across the system. We keep it as String to match
existing APIs (node names like “node@host”).
pub type NodeId =
String
Errors returned by registry operations.
pub type RegistryError {
NotFound
AlreadyExists
InvalidArgument(String)
AdapterFailure(String)
}
Constructors
-
NotFound -
AlreadyExists -
InvalidArgument(String) -
AdapterFailure(String)
Opaque state for registry implementations. Adapters may represent this however they like (actor state, ETS reference, etc.).
pub type RegistryState {
RegistryState
}
Constructors
-
RegistryState
Values
pub fn init() -> RegistryState
Initialize a fresh registry state. Implementations may accept config
via environment or separate constructors; the core can call init() when
creating an adapter instance.
pub fn list_nodes(
state: RegistryState,
) -> #(RegistryState, List(String))
Return the list of known node ids.
pub fn lookup(
state: RegistryState,
node_id: String,
) -> #(RegistryState, option.Option(Metadata))
Lookup node metadata. Returns Some(metadata) if present or None.
pub fn register(
state: RegistryState,
node_id: String,
metadata: Metadata,
) -> #(RegistryState, Result(Nil, RegistryError))
Register a node with associated metadata.
Returns the updated state and Ok(Nil) on success or Error(AdapterFailure(...)).
pub fn unregister(
state: RegistryState,
node_id: String,
) -> #(RegistryState, Result(Nil, RegistryError))
Unregister a node.