CouncilEx.PubSub.Adapter behaviour (CouncilEx v0.1.0)

Copy Markdown View Source

Behaviour for CouncilEx.PubSub backends.

Two stock implementations ship in core:

Summary

Callbacks

Adapter init: receives the config keyword (whatever was supplied in :pubsub) and returns {:ok, config} on success or {:error, reason} on misconfig. Adapters that need no config return {:ok, []}.

Callbacks

broadcast(topic, message)

@callback broadcast(topic :: String.t(), message :: term()) :: :ok

init(keyword)

@callback init(keyword()) :: {:ok, keyword()} | {:error, term()}

Adapter init: receives the config keyword (whatever was supplied in :pubsub) and returns {:ok, config} on success or {:error, reason} on misconfig. Adapters that need no config return {:ok, []}.

subscribe(topic)

@callback subscribe(topic :: String.t()) :: :ok

unsubscribe(topic)

@callback unsubscribe(topic :: String.t()) :: :ok