CouncilEx.PubSub (CouncilEx v0.1.0)

Copy Markdown View Source

Facade for the configured PubSub adapter.

Backed by CouncilEx.PubSub.PG (default, :pg-based) or CouncilEx.PubSub.Phoenix (delegating to a user-supplied Phoenix.PubSub server). Configure via:

config :council_ex, pubsub: :pg

# or:
config :council_ex,
  pubsub: {CouncilEx.PubSub.Phoenix, name: MyApp.PubSub}

The adapter is resolved once at application boot (inside the CouncilEx start callback) and stashed in :persistent_term for fast dispatch.

Summary

Functions

Resolve the configured adapter and stash it in :persistent_term. Called once at application start, and also re-callable from tests.

Broadcast message to every subscriber of topic.

Subscribe the calling process to topic.

Remove the calling process from topic.

Functions

__resolve__!()

@spec __resolve__!() :: :ok

Resolve the configured adapter and stash it in :persistent_term. Called once at application start, and also re-callable from tests.

broadcast(topic, message)

@spec broadcast(String.t(), term()) :: :ok

Broadcast message to every subscriber of topic.

subscribe(topic)

@spec subscribe(String.t()) :: :ok

Subscribe the calling process to topic.

unsubscribe(topic)

@spec unsubscribe(String.t()) :: :ok

Remove the calling process from topic.