macula_pubsub_routing (macula v0.14.3)
View SourcePub/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
-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.)
-spec should_deliver_locally(binary(), macula_protocol_types:pubsub_route_msg()) -> boolean().
Determine if this node should deliver the message locally or forward it.
-spec wrap_publish(binary(), binary(), macula_protocol_types:publish_msg(), pos_integer()) -> macula_protocol_types:pubsub_route_msg().
Wrap a PUBLISH message in pubsub_route envelope for DHT routing.