Skip to content

Dynamic Supervisor for gleam/erlang/otp

Notifications You must be signed in to change notification settings

kodumbeats/dinosoup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

4 Commits

Repository files navigation

kodumbeats/dinosoup

Package Version Hex Docs

A Elixir/DynamicSupervisor /:simple_one_for_one strategy for gleam/{erlang,otp}.

WORK IN PROGRESS - Use at your own risk pre v0.1.0 release onhex.

Usage

Add the library to your Gleam project:

gleam add dinosoup

Then, in your code:

importdinosoup
importsome.{message_handler}

pubfnmain(){
letassertOk(sup)=dinosoup.start()

// children must implement same behavior (e.g. use the same handler)
sup|>dinosoup.start_child(ChildSpec(["state"],message_handler))
sup|>dinosoup.start_child(ChildSpec(["different_state"],message_handler))

// to get at it later
let[#(pid,actor,spec),.._rest]=sup|>dinosoup.children()

// killed children stay dead, but Normal and Abnormal(reason)
// exits will be restarted
letassertOk(Nil)=sup|>dinosoup.kill_child(pid)

// and now only one remains
letassert[_]=sup|>dinosoup.children()
}

Further documentation can be found athttps://hexdocs.pm/dinosoup.

Development

gleam format#Format the code
gleam run#Run the project
gleamtest#Run the tests
gleam shell#Run an Erlang shell

TODO

  • Getdinosoup.kill_child/2working
  • Implement more sophisticated restart/timeout strategies
  • Harmonize more closely withgleam/otp/supervisorbehavior

made with <3 by kodumbeats

About

Dynamic Supervisor for gleam/erlang/otp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published