Skip to content

Commit

Permalink
Commanded 1.4.0 Part 1 (#2)
Browse files Browse the repository at this point in the history
* Fix error return in add_stream

* Rename concurrency option to be compatible with Commanded 1.4
  • Loading branch information
fabriziosestito authored Jul 6, 2022
1 parent c71e9df commit 6178702
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/commanded/event_store/adapters/spear/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Commanded.EventStore.Adapters.Spear.Subscription do
:serializer,
:stream,
:start_from,
:subscriber_max_count,
:concurrency_limit,
:subscriber,
:subscriber_ref,
:subscription,
Expand All @@ -38,7 +38,7 @@ defmodule Commanded.EventStore.Adapters.Spear.Subscription do
serializer: serializer,
subscriber: subscriber,
start_from: Keyword.get(opts, :start_from),
subscriber_max_count: Keyword.get(opts, :subscriber_max_count, 1),
concurrency_limit: Keyword.get(opts, :concurrency_limit, 1),
retry_interval: subscription_retry_interval()
}

Expand Down Expand Up @@ -168,11 +168,11 @@ defmodule Commanded.EventStore.Adapters.Spear.Subscription do
name: name,
stream: stream,
start_from: start_from,
subscriber_max_count: subscriber_max_count
concurrency_limit: concurrency_limit
} = state

settings = %Spear.PersistentSubscription.Settings{
max_subscriber_count: subscriber_max_count,
max_subscriber_count: concurrency_limit,
message_timeout: 10_000,
resolve_links?: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ defmodule Commanded.EventStore.Adapters.Spear.SubscriptionsSupervisor do
{:ok, pid}

{:error, {:already_started, _pid}} ->
case Keyword.get(opts, :subscriber_max_count) do
case Keyword.get(opts, :concurrency_limit) do
nil ->
{:error, :subscription_already_exists}

subscriber_max_count when index < subscriber_max_count - 1 ->
concurrency_limit when index < concurrency_limit - 1 ->
start_subscription(
event_store,
conn,
Expand Down
6 changes: 3 additions & 3 deletions lib/commanded/event_store/spear.ex
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ defmodule Commanded.EventStore.Adapters.Spear do
{:ok, _events} ->
add_to_stream(adapter_meta, stream, :any_version, events)

{:error, :stream_not_found} ->
{:error, :stream_does_not_exist}
err ->
err
end
end

Expand All @@ -240,7 +240,7 @@ defmodule Commanded.EventStore.Adapters.Spear do

case expected_version do
:no_stream -> {:error, :stream_exists}
:stream_exists -> {:error, :stream_does_not_exist}
:stream_exists -> {:error, :stream_not_found}
_expected_version -> {:error, :wrong_expected_version}
end

Expand Down

0 comments on commit 6178702

Please sign in to comment.