distribute/registry

Types

Errors from registry operations.

pub type RegisterError {
  AlreadyExists
  InvalidProcess
  InvalidArgument(String)
  NetworkError(String)
  RegistrationFailed(String)
}

Constructors

  • AlreadyExists

    Name is already registered by another process.

  • InvalidProcess

    Process is not alive or invalid.

  • InvalidArgument(String)

    Name is empty, too long, or contains invalid characters.

  • NetworkError(String)

    Network partition or connectivity issue.

  • RegistrationFailed(String)

    Generic registration failure.

A name bound to an encoder/decoder pair. The msg type links registration and lookup at compile time.

pub opaque type TypedName(msg)

Values

pub fn is_registered(name: String) -> Bool

Check whether a name is currently registered.

pub fn lookup(
  tn: TypedName(msg),
) -> Result(global.GlobalSubject(msg), Nil)

Look up a globally registered GlobalSubject by TypedName. Reconstructs the Subject with a deterministic tag from the name.

pub fn lookup_with_timeout(
  tn: TypedName(msg),
  timeout_ms: Int,
  poll_interval_ms: Int,
) -> Result(global.GlobalSubject(msg), Nil)

Look up with polling. Retries every poll_interval_ms until found or timeout_ms elapses.

pub fn named(name: String, c: codec.Codec(msg)) -> TypedName(msg)

Create a typed name from a bundled Codec.

pub fn pool_member(
  base: TypedName(msg),
  index: Int,
) -> TypedName(msg)

Derive a pool member name by appending the index.

pub fn register(
  name: String,
  pid: process.Pid,
) -> Result(Nil, RegisterError)

Register a PID under a global name.

pub fn register_global(
  tn: TypedName(msg),
  global_subject: global.GlobalSubject(msg),
) -> Result(Nil, RegisterError)

Register a GlobalSubject under a typed name. The compiler enforces that both sides share the same msg type.

pub fn register_typed(
  name: String,
  subject: process.Subject(msg),
) -> Result(Nil, RegisterError)

Register a Subject’s owner PID under a global name.

pub fn typed_name(
  name: String,
  encoder: fn(msg) -> Result(BitArray, codec.EncodeError),
  decoder: fn(BitArray) -> Result(msg, codec.DecodeError),
) -> TypedName(msg)

Create a typed name from separate encoder and decoder.

pub fn typed_name_decoder(
  tn: TypedName(msg),
) -> fn(BitArray) -> Result(msg, codec.DecodeError)

Get the decoder from a TypedName.

pub fn typed_name_encoder(
  tn: TypedName(msg),
) -> fn(msg) -> Result(BitArray, codec.EncodeError)

Get the encoder from a TypedName.

pub fn typed_name_to_string(tn: TypedName(msg)) -> String

Get the name string from a TypedName.

pub fn unregister(name: String) -> Result(Nil, RegisterError)

Unregister a global name.

Always succeeds — unregistering a non-existent name is a no-op.

pub fn whereis(name: String) -> Result(process.Pid, Nil)

Look up a globally registered PID by name.

Search Document