Pool

The Pool module provides actor pools for load balancing. Pools manage groups of actors with the same handler and route messages using configurable strategies.

Routing Strategies

:round-robin - Distributes messages evenly in order. :random - Selects random actor. :least-loaded - Sends to actor with smallest mailbox.

Pool Creation

Pool.create
String -> Handler -> State -> Int -> Keyword -> Result String PoolError
Creates a named pool with handler, initial state, size, and routing strategy.
Pool.create "workers" handler 0 4 :round-robin

Message Passing

Pool.send
String -> a -> Result Bool PoolError
Sends message to one actor based on routing strategy.
Pool.broadcast
String -> a -> Result Int PoolError
Sends message to all actors in the pool.

Pool Management

Pool.resize
String -> Int -> Result Int PoolError
Dynamically resize the pool.
Pool.delete
String -> Result Bool PoolError
Deletes a pool and stops all its actors.