Skip to content

chouzar/chip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chip - A subject registry for Gleam

Package Version Hex Docs

Chip is capable of registering a set of subjects as part of a group.

Example

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.

Run tests:

gleam test

Run benchmarks:

gleam run --module benchmark

Previous Art

This registry takes and combines some ideas from:

  • Elixir’s registry module.
  • Erlang's pg module.
  • The syn global registry library.

Other Gleam registry libraries

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.

Installation

gleam add chip

About

Registry library for gleam

Resources

Stars

Watchers

Forks

Packages

No packages published