distribute/receiver
Types
pub type Next(state) {
Continue(state)
Stop
StopAbnormal(reason: String)
}
Constructors
-
Continue(state) -
Stop -
StopAbnormal(reason: String)
pub type ReceiveError {
DecodeError(codec.DecodeError)
Timeout
}
Constructors
-
DecodeError(codec.DecodeError) -
Timeout
Values
pub fn receive_typed(
subject: process.Subject(BitArray),
decoder: fn(BitArray) -> Result(a, codec.DecodeError),
timeout_ms: Int,
) -> Result(a, ReceiveError)
Receive and decode one message.
pub fn selecting_typed(
selector: process.Selector(b),
subject: process.Subject(BitArray),
decoder: fn(BitArray) -> Result(a, codec.DecodeError),
mapper: fn(Result(a, ReceiveError)) -> b,
) -> process.Selector(b)
Add a typed handler to a Selector.
pub fn start_distributed_worker(
name: String,
initial_state: state,
encoder: fn(msg) -> Result(BitArray, codec.EncodeError),
decoder: fn(BitArray) -> Result(msg, codec.DecodeError),
handler: fn(msg, state) -> Next(state),
) -> Result(
actor.Started(global.GlobalSubject(msg)),
actor.StartError,
)
Start a distributed actor with a deterministic name-based tag. Remote nodes can reconstruct the Subject via registry.lookup.
pub fn start_receiver(
initial_state: state,
decoder: fn(BitArray) -> Result(msg, codec.DecodeError),
handler: fn(msg, state) -> Next(state),
) -> Result(process.Subject(BitArray), actor.StartError)
Start an OTP actor that decodes binary messages and forwards
them to handler. Returns the raw Subject(BitArray).