macula_rpc_routing (macula v0.20.5)
View SourceRPC routing for multi-hop DHT-routed RPC. Handles wrapping, unwrapping, and routing of RPC messages through the Kademlia DHT mesh.
Summary
Functions
Route an rpc_route message: either deliver locally or forward to next hop. Returns one of: {deliver, PayloadType, Payload} - Message is for this node {forward, NextHopNodeInfo, UpdatedRpcRouteMsg} - 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 CALL message in rpc_route envelope for DHT routing.
Wrap a REPLY message in rpc_route envelope for DHT routing back to caller.
Functions
-spec route_or_deliver(binary(), macula_protocol_types:rpc_route_msg(), pid()) -> {deliver, call | reply, map()} | {forward, macula_routing_bucket:node_info(), macula_protocol_types:rpc_route_msg()} | {error, term()}.
Route an rpc_route message: either deliver locally or forward to next hop. Returns one of: {deliver, PayloadType, Payload} - Message is for this node {forward, NextHopNodeInfo, UpdatedRpcRouteMsg} - Forward to next hop {error, Reason} - Cannot route (TTL exceeded, no route, etc.)
-spec should_deliver_locally(binary(), macula_protocol_types:rpc_route_msg()) -> boolean().
Determine if this node should deliver the message locally or forward it.
-spec wrap_call(binary(), binary(), macula_protocol_types:call_msg(), pos_integer()) -> macula_protocol_types:rpc_route_msg().
Wrap a CALL message in rpc_route envelope for DHT routing.
-spec wrap_reply(binary(), binary(), macula_protocol_types:reply_msg(), pos_integer()) -> macula_protocol_types:rpc_route_msg().
Wrap a REPLY message in rpc_route envelope for DHT routing back to caller.