glixir/agent

Types

pub opaque type Agent(state)
pub type AgentError {
  StartError(reason: String)
  Timeout
  AgentDown
  DecodeError(String)
}

Constructors

  • StartError(reason: String)
  • Timeout
  • AgentDown
  • DecodeError(String)

Values

pub fn cast(agent: Agent(state), fun: fn(state) -> state) -> Nil
pub fn get(
  agent: Agent(state),
  fun: fn(state) -> a,
  decoder: decode.Decoder(a),
) -> Result(a, AgentError)
pub fn get_and_update(
  agent: Agent(state),
  fun: fn(state) -> #(a, state),
  decoder: decode.Decoder(a),
) -> Result(a, AgentError)
pub fn get_timeout(
  agent: Agent(state),
  fun: fn(state) -> a,
  timeout: Int,
  decoder: decode.Decoder(a),
) -> Result(a, AgentError)
pub fn pid(agent: Agent(state)) -> process.Pid
pub fn start(
  initial_fun: fn() -> state,
) -> Result(Agent(state), AgentError)
pub fn start_named(
  name: atom.Atom,
  initial_fun: fn() -> state,
) -> Result(Agent(state), AgentError)
pub fn stop(
  agent: Agent(state),
  reason: atom.Atom,
) -> Result(Nil, AgentError)
pub fn update(
  agent: Agent(state),
  fun: fn(state) -> state,
) -> Result(Nil, AgentError)
Search Document