chip
A pure gleam process registry that plays along types and gleam OTP abstractions. Will automatically delist dead processes.
Example
import gleam/erlang/process
import chip
// Names can be built out of any primitive or even types.
type Name {
A
B
}
// We can start the registry and register a new subject
let assert Ok(registry) = chip.start()
chip.register(registry, A, process.new_subject())
// If we lose scope of our processes, just look it up in the registry!
let assert Ok(subject) = chip.find(registry, A)
let assert Error(chip.NotFound) = chip.find(registry, B)
Types
Functions
pub fn find(registry: Subject(Message(a, b)), name: a) -> Result(
Subject(b),
Errors,
)
Looks up a subject through its given name.
Example
> chit.find(reigstry, "MyProcess")
Ok(subject)
pub fn register(registry: Subject(Message(a, b)), name: a, subject: Subject(
b,
)) -> Nil
Manually registers a Subject
within the registry.
Example
> chit.register(registry, "MyProcess", process.new_subject())
Nil
pub fn start() -> Result(Subject(Message(a, b)), StartError)
Starts our registry.
Example
> chit.start()
Ok(registry)
pub fn unregister(registry: Subject(Message(a, b)), name: a) -> Nil
Manually unregister a Subject
within the registry.
Example
> chit.unregister(registry, "MyProcess")
Nil