chip
Chip is a gleam process registry that plays along gleam erlang/OTP Subject
type.
It lets us group subjects of the same type so that we can later reference them all as a group, or sub-group if we decide to name them. Will also automatically delist dead processes.
Types
Functions
pub fn all(registry: Subject(Message(a, b))) -> List(Subject(b))
Returns all registered Subject
s.
Example
> chip.all(registry)
[subject_a, subject_b, subject_c]
pub fn deregister(
registry: Subject(Message(a, b)),
name: a,
) -> Nil
Manually deregister a named group of Subject
s.
Example
> chip.deregister(registry, "MySubjects")
Nil
pub fn lookup(
registry: Subject(Message(a, b)),
name: a,
) -> List(Subject(b))
Looks up named subgroup of Subject
s.
Example
> chip.lookup(registry, "MySubjects")
[subject_a, subject_c]
pub fn register(
registry: Subject(Message(a, b)),
start: fn() -> Result(Subject(b), StartError),
) -> Result(Subject(b), StartError)
Manually registers a Subject
.
Example
> chip.register(registry, fn() { start_my_subject() })
Ok(registered_subject)
pub fn register_as(
registry: Subject(Message(a, b)),
name: a,
start: fn() -> Result(Subject(b), StartError),
) -> Result(Subject(b), StartError)
Manually registers a Subject
under a named group.
Example
> chip.register(registry, "MySubjects", fn() { start_my_subject() })
Ok(registered_subject)
pub fn start() -> Result(Subject(Message(a, b)), StartError)
Starts the registry.
Example
> chip.start()
Ok(registry)