Search documentation of macula

# macula_gateway_pubsub_router (macula v0.44.2)

View Source

Macula Gateway Pub/Sub Router - DHT-Routed Message Distribution

Handles distribution of pub/sub messages to both local and remote subscribers using multi-hop Kademlia DHT routing (v0.7.8+).

Responsibilities: - Deliver messages to local subscribers via QUIC streams - Query DHT for remote subscribers - Route messages via DHT multi-hop (pubsub_route protocol) - Wrap PUBLISH messages in pubsub_route envelopes

Extracted from macula_gateway.erl (v0.7.9) for better separation of concerns.

# Summary

## Functions

distribute(LocalSubscribers, PubMsg, LocalNodeId, Mesh, Clients)

Distribute pub/sub message to both local and remote subscribers. Uses DHT routing for remote subscribers (multi-hop Kademlia). For connected clients, uses existing bidirectional streams instead of mesh connections.

# Functions

# distribute(LocalSubscribers, PubMsg, LocalNodeId, Mesh, Clients)

    -spec distribute(LocalSubscribers :: [quicer:stream_handle()],
                     PubMsg :: map(),
                     LocalNodeId :: binary(),
                     Mesh :: pid(),
                     Clients :: pid()) ->
                        ok.

Distribute pub/sub message to both local and remote subscribers. Uses DHT routing for remote subscribers (multi-hop Kademlia). For connected clients, uses existing bidirectional streams instead of mesh connections.