macula_rpc_dht (macula v0.14.3)
View SourceDHT integration for finding RPC service providers. Uses Kademlia DHT to publish and discover RPC registrations. Wraps macula_discovery with RPC-specific types.
Summary
Functions
Announce local registration to DHT.
Filter providers to only available ones (based on last_seen TTL).
Find service providers for a URI via DHT.
Find providers with cache (default TTL: 300 seconds).
Find providers with cache and custom TTL.
Remove local registration from DHT.
Types
-type address() :: {inet:ip_address(), inet:port_number()}.
-type dht_lookup_fun() :: fun((uri()) -> {ok, [provider_info()]} | {error, term()}).
-type node_id() :: binary().
-type uri() :: binary().
Functions
Announce local registration to DHT.
-spec filter_available([provider_info()], pos_integer()) -> [provider_info()].
Filter providers to only available ones (based on last_seen TTL).
-spec find_providers(uri(), dht_lookup_fun()) -> {ok, [provider_info()]} | {error, term()}.
Find service providers for a URI via DHT.
-spec find_with_cache(uri(), macula_cache:cache(), dht_lookup_fun()) -> {ok, [provider_info()], macula_cache:cache()} | {error, term(), macula_cache:cache()}.
Find providers with cache (default TTL: 300 seconds).
-spec find_with_cache(uri(), macula_cache:cache(), dht_lookup_fun(), pos_integer()) -> {ok, [provider_info()], macula_cache:cache()} | {error, term(), macula_cache:cache()}.
Find providers with cache and custom TTL.
-spec unannounce(uri(), node_id(), dht_unpublish_fun()) -> ok | {error, term()}.
Remove local registration from DHT.