View Source Spear.PersistentSubscription (Spear v1.0.0)

A struct representing a persistent subscription and its settings

Link to this section Summary

Types

The action the EventStoreDB should take for an event's nack

t()

A persistent subscription.

Link to this section Types

Link to this type

nack_action()

View Source (since 0.6.0)
@type nack_action() :: :unknown | :park | :retry | :skip | :stop

The action the EventStoreDB should take for an event's nack

  • :park - stops the EventStoreDB from re-sending the event and appends a reference to the event to the persistent subscription's parked events stream. These events can be retried later by clicking the "Replay Parked Messages" button in the EventStoreDB dashboard's persistent subscriptions section for each stream+group combination. The EventStoreDB parking system is conceptually similar to dead letter queues.
  • :retry - retries the event up to :max_retry_count tries. This option is a reasonable default so that if a consumer hits a transient error condition such as a network timeout, it will retry the event before giving up and parking. Note that once a consumer has retried an event more than :max_retry_count times, the event is parked, even if the :retry action is given to Spear.nack/4.
  • :skip - skips the event without moving it to the parked events stream. Practically this is no different than simply Spear.ack/3ing the event(s) and performing a no-op in the consumer. Skipping may be a good option for dealing with poison messages: malformed or otherwise completely unhandleable events.
  • :stop - stops the EventStoreDB from re-sending the event. The event is not parked or retried. It is unclear how this differs from the :skip action. This function does not stop the persistent subscription: use Spear.cancel_subscription/3 to shut down the connection.
@type t() :: %Spear.PersistentSubscription{
  group_name: String.t(),
  settings: Spear.PersistentSubscription.Settings.t(),
  stream_name: String.t()
}

A persistent subscription.

These are generally returned from Spear.list_persistent_subscriptions/2.

Persistent subscriptions are considered unique by their stream name and group name pairings. A stream may have many different persistent subscriptions with different group names and settings and a group name may be used for multiple subscriptions to different streams.

examples

Examples

iex> Spear.create_persistent_subscription(conn, "my_stream", "my_group", %Spear.PersistentSubscription.Settings{})
:ok
iex> {:ok, subscriptions} = Spear.list_persistent_subscriptions(conn)
iex> subscriptions |> Enum.to_list()
[
  %Spear.PersistentSubscription{
    group_name: "my_group",
    settings: %Spear.PersistentSubscription.Settings{
      checkpoint_after: 3000,
      extra_statistics?: nil,
      history_buffer_size: 300,
      live_buffer_size: 100,
      max_checkpoint_count: 100,
      max_retry_count: 10,
      max_subscriber_count: 1,
      message_timeout: 5000,
      min_checkpoint_count: 1,
      named_consumer_strategy: :RoundRobin,
      read_batch_size: 100,
      resolve_links?: true,
      revision: 0
    },
    stream_name: "my_stream"
  }
]

Link to this section Functions

Link to this function

map_update_stream_option(stream_name, opts)

View Source