macula_pubsub_server (macula v0.20.5)

View Source

Pub/Sub GenServer - manages subscriptions and message delivery. Ties together registry, cache, discovery, and delivery layers.

Summary

Functions

Get cache statistics.

List all unique patterns.

List all subscriptions.

Publish message to all matching subscribers.

Start server with default options.

Start server with options.

Stop server.

Get subscription count.

Unsubscribe from a pattern.

Types

options/0

-type options() ::
          #{cache_size => pos_integer(),
            cache_ttl => pos_integer(),
            discovery_fun => macula_pubsub_discovery:dht_lookup_fun(),
            send_fun => macula_pubsub_delivery:send_fun()}.

Functions

cache_stats(Pid)

-spec cache_stats(pid()) -> #{size := non_neg_integer(), max_size := pos_integer()}.

Get cache statistics.

list_patterns(Pid)

-spec list_patterns(pid()) -> [binary()].

List all unique patterns.

list_subscriptions(Pid)

-spec list_subscriptions(pid()) -> [macula_pubsub_registry:subscription()].

List all subscriptions.

publish(Pid, Message)

-spec publish(pid(), macula_pubsub_delivery:message()) -> ok.

Publish message to all matching subscribers.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.

Start server with default options.

start_link(Options)

-spec start_link(options()) -> {ok, pid()} | {error, term()}.

Start server with options.

stop(Pid)

-spec stop(pid()) -> ok.

Stop server.

subscribe(Pid, SubscriberId, Pattern, Callback)

-spec subscribe(pid(), binary(), binary(), pid()) -> ok.

Subscribe to a pattern.

subscription_count(Pid)

-spec subscription_count(pid()) -> non_neg_integer().

Get subscription count.

unsubscribe(Pid, SubscriberId, Pattern)

-spec unsubscribe(pid(), binary(), binary()) -> ok.

Unsubscribe from a pattern.