macula_pubsub_discovery (macula v0.20.5)
View SourceDHT integration for finding remote subscribers. Uses Kademlia DHT to publish and discover subscriptions. Wraps macula_discovery with pub/sub-specific types.
Summary
Functions
Announce local subscription to DHT.
Find remote subscribers for a pattern via DHT.
Find subscribers with cache (default TTL: 300 seconds).
Find subscribers with cache and custom TTL.
Remove local subscription from DHT.
Types
-type address() :: {inet:ip_address(), inet:port_number()}.
-type dht_lookup_fun() :: fun((pattern()) -> {ok, [subscriber()]} | {error, term()}).
-type node_id() :: binary().
-type pattern() :: binary().
Functions
-spec announce(pattern(), node_id(), address(), dht_publish_fun()) -> ok | {error, term()}.
Announce local subscription to DHT.
-spec find_subscribers(pattern(), dht_lookup_fun()) -> {ok, [subscriber()]} | {error, term()}.
Find remote subscribers for a pattern via DHT.
-spec find_with_cache(pattern(), macula_cache:cache(), dht_lookup_fun()) -> {ok, [subscriber()], macula_cache:cache()} | {error, term(), macula_cache:cache()}.
Find subscribers with cache (default TTL: 300 seconds).
-spec find_with_cache(pattern(), macula_cache:cache(), dht_lookup_fun(), pos_integer()) -> {ok, [subscriber()], macula_cache:cache()} | {error, term(), macula_cache:cache()}.
Find subscribers with cache and custom TTL.
-spec unannounce(pattern(), node_id(), dht_unpublish_fun()) -> ok | {error, term()}.
Remove local subscription from DHT.