Search documentation of macula

# macula_pubsub_delivery (macula v0.44.2)

View Source

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

# Summary

## Types

delivery_result/0
discovery_fun/0
message/0
send_fun/0

## Functions

deliver_local(Message, Registry)

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

deliver_remote(Message, RemoteSubscribers, SendFun)

Deliver message to remote subscribers via QUIC.

get_matching_patterns(Topic, Registry)

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}.

# 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)

    -spec publish(message(), macula_pubsub_registry:registry(), discovery_fun(), send_fun()) ->
                     {[delivery_result()], [delivery_result()]}.

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