esdb_channel behaviour (erl_esdb_gater v0.6.6)

View Source

Channel behavior for erl-esdb-gater PubSub API SET

Defines the behavior that all channel implementations must follow. Each channel handles a specific type of message (events, metrics, etc.)

Channel priorities: - critical: alerts, security (no rate limit, HMAC required) - high: events, health - normal: metrics, system - low: logging, diagnostics

Summary

Functions

Get all subscribers for a topic

Publish a message to a channel topic

Publish with capability token for authorization

Start a channel

Subscribe to a channel topic

Subscribe with capability token for authorization

Unsubscribe from a channel topic

Types

channel_name/0

-type channel_name() :: atom().

priority/0

-type priority() :: critical | high | normal | low.

topic/0

-type topic() :: binary().

Functions

behaviour_info(Other)

get_subscribers(Channel, Topic)

-spec get_subscribers(channel_name(), topic()) -> [pid()].

Get all subscribers for a topic

publish(Channel, Topic, Message)

-spec publish(channel_name(), topic(), term()) -> ok | {error, term()}.

Publish a message to a channel topic

publish(Channel, Topic, Message, CapabilityToken)

-spec publish(channel_name(), topic(), term(), binary()) -> ok | {error, term()}.

Publish with capability token for authorization

start_link(Module, Opts)

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

Start a channel

subscribe(Channel, Topic, Pid)

-spec subscribe(channel_name(), topic(), pid()) -> ok | {error, term()}.

Subscribe to a channel topic

subscribe(Channel, Topic, Pid, CapabilityToken)

-spec subscribe(channel_name(), topic(), pid(), binary()) -> ok | {error, term()}.

Subscribe with capability token for authorization

unsubscribe(Channel, Topic, Pid)

-spec unsubscribe(channel_name(), topic(), pid()) -> ok.

Unsubscribe from a channel topic