Spear.create_persistent_subscription

You're seeing just the function create_persistent_subscription, go back to Spear module for more information.
Link to this function

create_persistent_subscription(conn, stream_name, group_name, settings, opts \\ [])

View Source (since 0.6.0)

Specs

create_persistent_subscription(
  connection :: Spear.Connection.t(),
  stream_name :: String.t() | :all,
  group_name :: String.t(),
  settings :: Spear.PersistentSubscription.Settings.t(),
  opts :: Keyword.t()
) :: :ok | {:error, any()}

Creates a persistent subscription

See Spear.PersistentSubscription.Settings.t/0 for more information.

Note that persistent subscriptions to the :all stream with server-side filtering is a feature introduced in EventStoreDB v21.6.0. Attempting to use the :all stream on older EventStoreDB versions will fail.

Options

  • :from - the position or revision in the stream where the persistent subscription should start. This option may be :start or :end describing the beginning or end of the stream. When the stream_name is :all, this paramater describes the prepare and commit positions in the :all stream which can be found on any event emitted from a subscription to the :all stream. When the stream_name is not the :all stream, this option may be an integer representing the event number in the stream from which the subscription should start. This may be found on any Spear.Event.t/0. This option may be passed a Spear.Event.t/0, from which either the revision or position will be determined based on the stream name. This option overwrites the :revision field on the Spear.PersistentSubscription.Settings.t/0 type which is now deprecated.

  • :filter - a filter to apply while reading from the :all stream. This option only applies when reading the :all stream. The same data structure works for regular and persistent subscriptions to the :all stream. See the Spear.Filter.t/0 documentation for more information.

Remaining options are passed to request/5.

Examples

iex> Spear.create_persistent_subscription(conn, "my_stream", "my_group", %Spear.PersistentSubscription.Settings{})
:ok
iex> import Spear.Filter
iex> filter = ~f/My.Aggregate.A- My.Aggregate.B-/ps
iex> Spear.create_persistent_subscription(conn, :all, "my_all_group", %Spear.PersistentSubscription.Settings{}, filter: filter)
:ok