Spear.nack

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

nack(conn, subscription, event_or_ids, opts \\ [])

View Source (since 0.6.0)

Specs

nack(
  connection :: Spear.Connection.t(),
  subscription :: reference(),
  event_or_ids :: Spear.Event.t() | [String.t()],
  opts :: Keyword.t()
) :: :ok

Negatively acknowldeges a persistent subscription event

Nacking is the opposite of ack/3ing: it tells the EventStoreDB that the event should not be considered processed.

Options

  • :action - (default: :retry) controls the action the EventStoreDB should take about the event. See Spear.PersistentSubscription.nack_action/0 for a full description.
  • :reason - (default: "") a description of why the event is being nacked

Examples

# some stream with 3 events
stream_name = "my_stream"
group_name = "spear_iex"
settings = %Spear.PersistentSubscription.Settings{}

get_event_and_ack = fn conn, sub, action ->
  receive do
    %Spear.Event{} = event ->
      :ok = Spear.nack(conn, sub, event, action: action)

      event

  after
    3_000 -> :no_events
  end
end

iex> Spear.create_persistent_subscription(conn, stream_name, group_name, settings)
:ok
iex> {:ok, sub} = Spear.connect_to_persistent_subscription(conn, self(), stream_name, group_name)
iex> get_event_and_nack.(conn, sub, :retry)
%Spear.Event{..} # event 0
iex> get_event_and_nack.(conn, sub, :retry)
%Spear.Event{..} # event 0
iex> get_event_and_nack.(conn, sub, :park) # park event 0 and move on
%Spear.Event{..} # event 0
iex> get_event_and_nack.(conn, sub, :skip) # skip event 1
%Spear.Event{..} # event 1
iex> get_event_and_nack.(conn, sub, :skip) # skip event 2
%Spear.Event{..} # event 2
iex> get_event_and_nack.(conn, sub, :skip)
:no_events
iex> Spear.cancel_subscription(conn, sub)
:ok