macula_rpc_routing (macula v0.20.5)

View Source

RPC 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

route_or_deliver(LocalNodeId, RpcRouteMsg, RoutingServerPid)

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

should_deliver_locally(LocalNodeId, RpcRouteMsg)

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

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

wrap_call(SourceNodeId, DestinationNodeId, CallMsg, MaxHops)

Wrap a CALL message in rpc_route envelope for DHT routing.

wrap_reply(SourceNodeId, DestinationNodeId, ReplyMsg, MaxHops)

Wrap a REPLY message in rpc_route envelope for DHT routing back to caller.