macula_direct_routing (macula v0.14.3)
View SourceDirect Routing Table - Bypass bootstrap for known subscriber endpoints.
Problem: Every publish goes through bootstrap even for known subscribers. Solution: Cache {NodeId, Endpoint} mappings and route directly via QUIC.
Design: - ETS table for O(1) lookup by NodeId - TTL-based expiration (default 5 minutes) - Automatic cleanup of stale entries - Thread-safe concurrent reads
Expected improvement: - 3-5x latency reduction for messages to known subscribers - Reduced load on bootstrap gateway
Configuration Options: - ttl_ms: Route entry TTL (default: 300000ms = 5 minutes) - cleanup_interval_ms: How often to clean stale entries (default: 60000ms)
Summary
Functions
Clear all routing entries.
Look up endpoint for a node ID. Returns {ok, Endpoint} on hit, or miss on cache miss/expired.
Remove routing entry for a node ID.
Start the direct routing table with default options.
Start the direct routing table with options. Options: - ttl_ms: Route entry TTL in milliseconds (default: 300000) - cleanup_interval_ms: Cleanup interval (default: 60000)
Get routing table statistics.
Store endpoint for a node ID. Entry will expire after TTL.
Store routing info from a subscriber map (from DHT lookup). Extracts node_id and endpoint from subscriber info.
Functions
-spec clear_all() -> ok.
Clear all routing entries.
Look up endpoint for a node ID. Returns {ok, Endpoint} on hit, or miss on cache miss/expired.
-spec remove(binary()) -> ok.
Remove routing entry for a node ID.
Start the direct routing table with default options.
Start the direct routing table with options. Options: - ttl_ms: Route entry TTL in milliseconds (default: 300000) - cleanup_interval_ms: Cleanup interval (default: 60000)
-spec stats() -> map().
Get routing table statistics.
Store endpoint for a node ID. Entry will expire after TTL.
-spec store_from_subscriber(map()) -> ok.
Store routing info from a subscriber map (from DHT lookup). Extracts node_id and endpoint from subscriber info.