Search documentation of macula

# macula_rpc_routing (macula v0.44.2)

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_or_deliver(LocalNodeId, RpcRouteMsg, RoutingServerPid)

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)

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.

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

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

# wrap_reply(SourceNodeId, DestinationNodeId, ReplyMsg, MaxHops)

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