relay_supervisor
A supervisor where older children can pass data to younger children!
This is useful any time a child needs to make use of another. For example, if you have a web server that uses a database connection.
gleam add relay_supervisor@1
import relay_supervisor as relay
fn start(credentials: String, hostname: String) -> _ {
relay.new(fn(children) {
children
|> relay.add(
relay.child(database.template)
|> relay.providing(fn(_state) { credentials })
|> relay.returning(fn(_state, db) { db })
)
|> relay.add(
relay.child(web_server.template)
|> relay.providing(fn(db) { #(db, hostname) })
)
})
}
See HexDocs for an explanation of this code and for further documentation.