Search documentation of macula

# macula_pubsub_server (macula v0.44.2)

View Source

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

# Summary

## Types

options/0

## Functions

cache_stats(Pid)

Get cache statistics.

list_patterns(Pid)

List all unique patterns.

list_subscriptions(Pid)

List all subscriptions.

publish(Pid, Message)

Publish message to all matching subscribers.

start_link()

Start server with default options.

start_link(Options)

Start server with options.

stop(Pid)

Stop server.

subscribe(Pid, SubscriberId, Pattern, Callback)

Subscribe to a pattern.

subscription_count(Pid)

Get subscription count.

unsubscribe(Pid, SubscriberId, Pattern)

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.