Hive.Pubsub.Make.T

hive · API reference

A concrete pubsub transport.

Implement this signature when you want Hive servers to publish and subscribe through your own bus: Valkey, NATS, Postgres LISTEN/NOTIFY, an in-memory test bus, or an application-specific bridge.

The transport owns its lifecycle and error policy. The generated t capability has unit-returning publish, so transports that can fail should decide whether to drop, log, reconnect, or expose diagnostics on their own handle.

type t

Runtime handle for the transport.

val publish : t -> topic:string -> payload:string -> unit

Publish an opaque payload to topic.

val subscribe : t -> topic:string -> (payload:string -> unit) -> unsubscribe

Subscribe a callback to topic.

The returned function releases just this subscription. It should be safe to call more than once.