Chip - A subject registry for Gleam
Chip enables you to register a set of subjects as part of a group.
Example
We can categorize subjects in groups, then send messages to them:
import artifacts/game.{DrawCard, FireDice, PlayChip}
import chip
import gleam/list
pub type Group {
GroupA
GroupB
}
pub fn main() {
let assert Ok(registry) = chip.start(chip.Unnamed)
let assert Ok(session_a) = game.start(DrawCard)
let assert Ok(session_b) = game.start(FireDice)
let assert Ok(session_c) = game.start(PlayChip)
chip.register(registry, GroupA, session_a)
chip.register(registry, GroupB, session_b)
chip.register(registry, GroupA, session_c)
chip.members(registry, GroupA, 50)
|> list.each(fn(session) { game.next(session) })
}
For more check the docs and guildelines.
Development
New additions to the API will be considered with care. Features are documented as Issues on the project’s repo, if you have questions or like to see a new feature please open an issue.
For benchmarks run:
gleam run --module benchmark
Previous Art
This registry takes and combines some ideas from:
Other Gleam registry libraries
Other registry libraries will provide different semantics and functionality:
- Singularity is designed to register a fixed number of actors, each of which may have a different message type.
Installation
gleam add chip