macula_pubsub_routing (macula v0.14.3)

View Source

Pub/Sub routing for multi-hop DHT-routed pub/sub. Handles wrapping, unwrapping, and routing of PUBLISH messages through the Kademlia DHT mesh.

Pattern: Clone of macula_rpc_routing for pub/sub messages

Summary

Functions

Route a pubsub_route message: either deliver locally or forward to next hop. Returns one of: {deliver, Topic, PublishMsg} - Message is for this node {forward, NextHopNodeInfo, UpdatedPubSubRouteMsg} - Forward to next hop {error, Reason} - Cannot route (TTL exceeded, no route, etc.)

Determine if this node should deliver the message locally or forward it.

Wrap a PUBLISH message in pubsub_route envelope for DHT routing.

Functions

route_or_deliver(LocalNodeId, PubSubRouteMsg, RoutingServerPid)

-spec route_or_deliver(binary(), macula_protocol_types:pubsub_route_msg(), pid()) ->
                          {deliver, binary(), map()} |
                          {forward,
                           macula_routing_bucket:node_info(),
                           macula_protocol_types:pubsub_route_msg()} |
                          {error, term()}.

Route a pubsub_route message: either deliver locally or forward to next hop. Returns one of: {deliver, Topic, PublishMsg} - Message is for this node {forward, NextHopNodeInfo, UpdatedPubSubRouteMsg} - Forward to next hop {error, Reason} - Cannot route (TTL exceeded, no route, etc.)

should_deliver_locally(LocalNodeId, PubSubRouteMsg)

-spec should_deliver_locally(binary(), macula_protocol_types:pubsub_route_msg()) -> boolean().

Determine if this node should deliver the message locally or forward it.

wrap_publish(SourceNodeId, DestinationNodeId, PublishMsg, MaxHops)

Wrap a PUBLISH message in pubsub_route envelope for DHT routing.