Skip to content

Subscription concurrency#134

Merged
slashdotdash merged 20 commits into
masterfrom
feature/concurrency
Sep 18, 2018
Merged

Subscription concurrency#134
slashdotdash merged 20 commits into
masterfrom
feature/concurrency

Conversation

@slashdotdash

@slashdotdash slashdotdash commented Sep 1, 2018

Copy link
Copy Markdown
Member

Allow multiple subscribers to connect to a single subscription, allowing concurrent event processing and load balancing between all connected subscriber processes.

Connecting more than one subscriber to a subscription will mean that event handling order is no longer guaranteed since events will be processed concurrently. However you can provide a partition_by function to return a partition key from an event. This will guarantee events for the same key will be handled in order. You might use an aggregate's identity as the partition key to have events for each aggregate instance ordered.

Example usage

{:ok, subscription} =
  EventStore.subscribe_to_all_streams(
    "example",
    subscriber1,
    concurrency_limit: 2
  )

{:ok, ^subscription} =
  EventStore.subscribe_to_all_streams(
    "example",
    subscriber2,
    concurrency_limit: 2
  )

{:error, :too_many_subscribers} =
  EventStore.subscribe_to_all_streams("example", subscriber3, concurrency_limit: 2)

See the Subscription concurrency section in the subscription guide for more detail.

Fixes #124.

@slashdotdash slashdotdash force-pushed the feature/concurrency branch 2 times, most recently from 3b8d388 to 405c6bd Compare September 2, 2018 22:07
@ababushkin

Copy link
Copy Markdown

👍

@slashdotdash slashdotdash merged commit 02e1583 into master Sep 18, 2018
@slashdotdash slashdotdash deleted the feature/concurrency branch September 18, 2018 11:21
@ababushkin

Copy link
Copy Markdown

Heroic effort! This is going to bring some exciting capabilities to commanded.

renanlage pushed a commit to stone-payments/eventstore that referenced this pull request Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants