glixir/registry

Registry support for Subject lookup with dynamic spawning

This module provides a Gleam-friendly interface to Elixir’s Registry, using our Elixir helper module for clean data conversion.

Types

Opaque type representing a registry process

pub opaque type Registry

Errors from registry operations

pub type RegistryError {
  StartError(reason: String)
  RegisterError(reason: String)
  LookupError(reason: String)
  UnregisterError(reason: String)
  AlreadyExists
  NotFound
}

Constructors

  • StartError(reason: String)
  • RegisterError(reason: String)
  • LookupError(reason: String)
  • UnregisterError(reason: String)
  • AlreadyExists
  • NotFound

Registry configuration options

pub type RegistryKeys {
  Unique
  Duplicate
}

Constructors

  • Unique
  • Duplicate
pub type RegistryLookupResult(message) {
  RegistryLookupOk(subject: process.Subject(message))
  RegistryLookupNotFound
  RegistryLookupError(reason: dynamic.Dynamic)
}

Constructors

pub type RegistryRegisterResult {
  RegistryRegisterOk
  RegistryRegisterError(reason: dynamic.Dynamic)
}

Constructors

pub type RegistryStartResult {
  RegistryStartOk(pid: process.Pid)
  RegistryStartError(reason: dynamic.Dynamic)
}

Constructors

pub type RegistryUnregisterResult {
  RegistryUnregisterOk
  RegistryUnregisterError(reason: dynamic.Dynamic)
}

Constructors

Values

pub fn lookup_subject(
  registry_name: String,
  key: String,
) -> Result(process.Subject(message), RegistryError)

Look up a Subject by key in the registry

pub fn lookup_with_key(
  registry_name: String,
  key: String,
) -> Result(process.Subject(message), RegistryError)

Look up a subject by custom key

pub fn register_subject(
  registry_name: String,
  key: String,
  subject: process.Subject(message),
) -> Result(Nil, RegistryError)

Register a Subject with a key in the registry

pub fn register_with_key(
  registry_name: String,
  key: String,
  subject: process.Subject(message),
) -> Result(Nil, RegistryError)

Register a subject with a custom key

pub fn start_registry(
  name: String,
  keys: RegistryKeys,
) -> Result(Registry, RegistryError)

Start a new Registry with the given name and key type

pub fn start_unique_registry(
  name: String,
) -> Result(Registry, RegistryError)

Start a unique key registry (most common use case)

pub fn unregister_subject(
  registry_name: String,
  key: String,
) -> Result(Nil, RegistryError)

Unregister a key from the registry

pub fn unregister_with_key(
  registry_name: String,
  key: String,
) -> Result(Nil, RegistryError)

Unregister a subject by custom key

Search Document