distribute/registry/actor

Types

pub type RegistryCommand {
  Register(
    String,
    behaviour.Metadata,
    process.Subject(Result(Nil, String)),
  )
  Unregister(String, process.Subject(Result(Nil, String)))
  Lookup(
    String,
    process.Subject(Result(behaviour.Metadata, Nil)),
  )
  ListAll(process.Subject(Result(List(String), Nil)))
}

Constructors

Values

pub fn child_spec() -> supervision.ChildSpecification(
  process.Subject(RegistryCommand),
)

Create a ChildSpecification for use with gleam_otp supervisors.

Example:

children: [distribute/registry/actor.child_spec()]
pub fn list_nodes_sync(
  registry: process.Subject(RegistryCommand),
  timeout_ms: Int,
) -> List(String)

List known node ids synchronously.

pub fn lookup_sync(
  registry: process.Subject(RegistryCommand),
  timeout_ms: Int,
  node_id: String,
) -> Result(behaviour.Metadata, behaviour.RegistryError)

Typed synchronous lookup helper.

pub fn register_sync(
  registry: process.Subject(RegistryCommand),
  timeout_ms: Int,
  node_id: String,
  metadata: behaviour.Metadata,
) -> Result(Nil, behaviour.RegistryError)

Typed synchronous helper: register node metadata via the registry actor.

pub fn start() -> Result(
  process.Subject(RegistryCommand),
  actor.StartError,
)

Start the registry actor. Returns a Subject(RegistryCommand) which accepts the commands defined above.

pub fn start_link() -> Result(
  actor.Started(process.Subject(RegistryCommand)),
  actor.StartError,
)

Start the registry actor returning the raw actor.Started result.

Useful for OTP supervision where the supervisor expects a start function that returns Result(actor.Started(data), actor.StartError).

pub fn unregister_sync(
  registry: process.Subject(RegistryCommand),
  timeout_ms: Int,
  node_id: String,
) -> Result(Nil, behaviour.RegistryError)

Typed synchronous unregister helper.

Search Document