macula_pubsub_delivery (macula v0.14.3)

View Source

Message routing and delivery to local and remote subscribers. Combines local registry and remote discovery for full fan-out.

Summary

Functions

Deliver message to all matching local subscribers. Crashes if subscriber callback fails - indicates dead subscriber process.

Deliver message to remote subscribers via QUIC.

Get all unique patterns that match the topic. Used for remote subscriber discovery.

Publish message to both local and remote subscribers. Returns {LocalResults, RemoteResults}.

Types

delivery_result/0

-type delivery_result() :: ok | {ok, term()} | {error, term()}.

discovery_fun/0

-type discovery_fun() :: fun((binary()) -> {ok, [map()]} | {error, term()}).

message/0

-type message() :: #{topic := binary(), payload := term(), timestamp := integer()}.

send_fun/0

-type send_fun() :: fun((message(), macula_pubsub_discovery:address()) -> ok | {error, term()}).

Functions

deliver_local(Message, Registry)

-spec deliver_local(message(), macula_pubsub_registry:registry()) -> [delivery_result()].

Deliver message to all matching local subscribers. Crashes if subscriber callback fails - indicates dead subscriber process.

deliver_remote(Message, RemoteSubscribers, SendFun)

-spec deliver_remote(message(), [macula_pubsub_discovery:subscriber()], send_fun()) ->
                        [delivery_result()].

Deliver message to remote subscribers via QUIC.

get_matching_patterns(Topic, Registry)

-spec get_matching_patterns(binary(), macula_pubsub_registry:registry()) -> [binary()].

Get all unique patterns that match the topic. Used for remote subscriber discovery.

publish(Message, Registry, DiscoveryFun, SendFun)

Publish message to both local and remote subscribers. Returns {LocalResults, RemoteResults}.