From 2fc902497c89e81b875307bdffb51156bce110e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl?= Date: Fri, 10 May 2024 00:08:56 -0700 Subject: [PATCH] Update docs --- README.md | 8 ++++---- gleam.toml | 2 +- src/chip/group.gleam | 8 ++++---- src/chip/registry.gleam | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a55726b..b405b71 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/chip/) -Chip is a gleam process registry that plays along the [Gleam Erlang](https://hexdocs.pm/gleam_erlang/) `Subject` type. +A local process registry that plays along Gleam's [Subject](https://hexdocs.pm/gleam_erlang/gleam/erlang/process.html#Subject) type. It lets tag subjects under a name or group to later reference them. Will also automatically delist dead processes. @@ -67,18 +67,18 @@ pub fn main() { Later, we may retrieve members for a group: ```gleam -let assert [a, b, c] = group.members(registry, GroupA) +let assert [a, b, c] = group.members(registry, "counters") let assert 6 = counter.current(a) + counter.current(b) + counter.current(c) ``` -Or dispatch a command for each `Subject`:: +Or broadcast a message to each Subject: ```gleam group.dispatch(registry, "counters", fn(counter) { actor.increment(counter) }) -let assert [a, b, c] = group.members(registry, GroupA) +let assert [a, b, c] = group.members(registry, "counters") let assert 9 = counter.current(a) + counter.current(b) + counter.current(c) ``` diff --git a/gleam.toml b/gleam.toml index cc63792..ed63e5a 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "chip" -version = "0.6.0" +version = "0.6.1" description = "A Gleam registry library" licences = ["Apache-2.0"] diff --git a/src/chip/group.gleam b/src/chip/group.gleam index 8f7c494..702dd8d 100644 --- a/src/chip/group.gleam +++ b/src/chip/group.gleam @@ -1,4 +1,4 @@ -//// This module helps group different `Subject`s under a name to later reference or broadcast messages to them. +//// This is a local process registry that groups Subjects under a name to later reference or broadcast messages to them. import gleam/dict.{type Dict} import gleam/erlang/process.{ @@ -76,7 +76,7 @@ pub fn start() -> Result(Registry(group, msg), actor.StartError) { )) } -/// Registers a `Subject` under a shared name. +/// Registers a Subject under a shared name. /// /// ## Example /// @@ -92,7 +92,7 @@ pub fn register( process.send(registry, GroupedRegistrant(subject, group)) } -/// Looks up `Subject`s under a named group. +/// Looks up Subjects under a named group. /// /// ### Example /// @@ -104,7 +104,7 @@ pub fn members(registry, group) -> List(Subject(msg)) { process.call(registry, GroupedSubjects(_, group), 10) } -/// Executes a callback for all `Subject`s under a named group. +/// Executes a callback for all Subjects under a named group. /// /// ### Example /// diff --git a/src/chip/registry.gleam b/src/chip/registry.gleam index fb6be4c..d8261ad 100644 --- a/src/chip/registry.gleam +++ b/src/chip/registry.gleam @@ -1,4 +1,4 @@ -//// This module helps tag `Subject`s under a name to later reference them. +//// This is a local process registry that individually tags Subjects for later reference. import gleam/dict.{type Dict} import gleam/erlang/process.{ @@ -63,7 +63,7 @@ pub fn start() -> Result(Registry(name, msg), actor.StartError) { )) } -/// Registers a `Subject` under a unique name. +/// Registers a Subject under a unique name. /// /// ## Example /// @@ -79,7 +79,7 @@ pub fn register( process.send(registry, Registrant(subject, name)) } -/// Looks up a uniquely named `Subject`. +/// Looks up a uniquely named Subject. /// /// ### Example ///