distribute/sugar
Types
pub type RequestError {
RegistrationFailed
SendFailed(messaging.SendError)
ReceiveFailed(receiver.ReceiveError)
}
Constructors
-
RegistrationFailed -
SendFailed(messaging.SendError) -
ReceiveFailed(receiver.ReceiveError)
Values
pub fn lookup_and_send(
name: String,
msg: a,
encoder: fn(a) -> Result(BitArray, codec.EncodeError),
) -> Result(Nil, messaging.SendError)
Look up a global name and send a typed message in one operation. This is more efficient than separate lookup + send.
pub fn receive_with_retry(
subject: process.Subject(BitArray),
decoder: fn(BitArray) -> Result(a, codec.DecodeError),
timeout_ms: Int,
max_attempts: Int,
) -> Result(a, receiver.ReceiveError)
Receive a typed message with timeout and automatic retry.
pub fn request(
target: String,
request: req,
request_encoder: fn(req) -> Result(BitArray, codec.EncodeError),
response_decoder: fn(BitArray) -> Result(
resp,
codec.DecodeError,
),
timeout_ms: Int,
) -> Result(resp, RequestError)
Create a request-response pattern: send and wait for reply.
pub fn send_with_retry(
subject: process.Subject(BitArray),
msg: a,
encoder: fn(a) -> Result(BitArray, codec.EncodeError),
max_attempts: Int,
) -> Result(Nil, messaging.SendError)
Send a typed message with automatic retry on failure.