Chronik v0.1.2 Chronik.PubSub behaviour View Source

PubSub adapter contract.

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 pub_sub

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. Note: events could still be on the mailbox

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 pub_sub

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.

Unsubscribes the caller from the PubSub. No further events are received from the PubSub. Note: events could still be on the mailbox.