macula_discovery (macula v0.20.5)
View SourceGeneric DHT-based service discovery. Provides cache-integrated lookup and announcement operations. Used by both pub/sub and RPC discovery layers.
Summary
Functions
Announce value to DHT.
Filter items by age based on last_seen timestamp and TTL. Items must have #{last_seen := integer()} in their structure.
Find values for a key via DHT lookup.
Find values with cache (default TTL: 300 seconds).
Find values with cache and custom TTL.
Remove value from DHT.
Types
Functions
-spec announce(key(), publish_fun()) -> ok | {error, term()}.
Announce value to DHT.
-spec filter_by_age([map()], pos_integer(), atom()) -> [map()].
Filter items by age based on last_seen timestamp and TTL. Items must have #{last_seen := integer()} in their structure.
-spec find(key(), lookup_fun()) -> {ok, [value()]} | {error, term()}.
Find values for a key via DHT lookup.
-spec find_with_cache(key(), macula_cache:cache(), lookup_fun()) -> {ok, [value()], macula_cache:cache()} | {error, term(), macula_cache:cache()}.
Find values with cache (default TTL: 300 seconds).
-spec find_with_cache(key(), macula_cache:cache(), lookup_fun(), pos_integer()) -> {ok, [value()], macula_cache:cache()} | {error, term(), macula_cache:cache()}.
Find values with cache and custom TTL.
-spec unannounce(key(), unpublish_fun()) -> ok | {error, term()}.
Remove value from DHT.