Chip is capable of registering a set of subjects as part of a group.
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.
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.
Run tests:
gleam test
Run benchmarks:
gleam run --module benchmark
This registry takes and combines some ideas from:
Other registry libraries will provide different semantics and functionality:
- Singularity is designed to register a fixed number of actors, where each one may have a different message type.
gleam add chip