Chronik v0.1.10 Chronik.PubSub behaviour View Source

Chronik.PubSub adapter contract and API.

In Chronik there is only one feed (all). This means that subscribers see a total ordering of events.

Link to this section Summary

Types

The result status of all operations on the Chronik.PubSub

Callbacks

Broadcasts an enumeration of records to all the subscribers

Subscribes the caller to the PubSub

Unsubscribes the caller from the PubSub. No further events are received from the PubSub

Link to this section Types

Link to this type result_status() View Source
result_status() :: :ok | {:error, String.t()}

The result status of all operations on the Chronik.PubSub

Link to this section Functions

Link to this section Callbacks

Link to this callback broadcast(records) View Source
broadcast(records :: [Chronik.EventRecord]) :: result_status()

Broadcasts an enumeration of records to all the subscribers.

Link to this callback subscribe(opts) View Source
subscribe(opts :: Keyword.t()) :: result_status()

Subscribes the caller to the PubSub.

Multiple subscriptions to the PubSub are allowed. The subscriber will receive the events multiple times.

The accepted options are:

  • consistency: :eventual (default) or :strict
Link to this callback unsubscribe() View Source
unsubscribe() :: result_status()

Unsubscribes the caller from the PubSub. No further events are received from the PubSub.

note: events could still be on the subscribers’ mailbox.