Hive.Addr

hive · API reference

Typed send capabilities.

A typed send capability — the PID analog.

An address is the only way to put a message in a worker's mailbox. It is typed by the message it accepts, so illegal sends are unrepresentable. Local-only in hive.core; the cluster layer extends addressing with node identity and incarnation fencing.

type 'msg t

An address accepting messages of type 'msg.

The type parameter is the send contract. If a worker expects Counter.Incr, an address for string cannot be used by accident.

val send : 'msg t -> 'msg -> (unit, [ `Closed ]) result

send addr msg enqueues msg in the target mailbox. Blocks when the mailbox is full (backpressure). Error Closed` if the target has stopped.

ocaml]
match Hive.Addr.send counter_addr `Incr with
| Ok () -> ()
| Error `Closed -> traceln "counter is gone"
val id : _ t -> int

Process-unique identifier of the address.

This is useful for logging and local diagnostics, not for persistence or cross-process addressing.

val equal : _ t -> _ t -> bool

Identity comparison (by id).

The message types may differ because equality checks only local address identity.

val make : enqueue:('msg -> (unit, [ `Closed ]) result) -> 'msg t

Runtime constructor used by Worker and Server; applications normally never call this.

It is mainly useful for adapters, for example mapping a remote Unreachable` send into the local Closed` convention.