Skip to content

Commit

Permalink
fix ack/3 and nack/4 to respect link IDs
Browse files Browse the repository at this point in the history
connects #37
  • Loading branch information
the-mikedavis committed Apr 29, 2021
1 parent ce0acb8 commit fe7e959
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/spear.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1941,13 +1941,13 @@ defmodule Spear do
gRPC call acknowledges a batch of event IDs.
```elixir
Spear.ack(conn, subscription, events |> Enum.map(& &1.id))
Spear.ack(conn, subscription, events |> Enum.map(&Spear.Event.id/1))
```
should be preferred over
```elixir
Enum.each(events, &Spear.ack(conn, subscription, &1.id))
Enum.each(events, &Spear.ack(conn, subscription, Spear.Event.id(&1)))
```
As the acknowledgements will be batched.
Expand Down Expand Up @@ -1997,7 +1997,7 @@ defmodule Spear do
) :: :ok
def ack(conn, subscription, event_or_ids)

def ack(conn, sub, %Spear.Event{id: id}), do: ack(conn, sub, [id])
def ack(conn, sub, %Spear.Event{} = event), do: ack(conn, sub, [Spear.Event.id(event)])

def ack(conn, sub, event_ids) when is_list(event_ids) do
id = ""
Expand Down Expand Up @@ -2070,7 +2070,8 @@ defmodule Spear do
def nack(conn, subscription, event_or_ids, opts \\ [])
# coveralls-ignore-stop

def nack(conn, sub, %Spear.Event{id: id}, opts), do: nack(conn, sub, [id], opts)
def nack(conn, sub, %Spear.Event{} = event, opts),
do: nack(conn, sub, [Spear.Event.id(event)], opts)

def nack(conn, sub, event_ids, opts) when is_list(event_ids) do
reason = Keyword.get(opts, :reason, "")
Expand Down

0 comments on commit fe7e959

Please sign in to comment.