Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription concurrency #134

Merged
merged 20 commits into from
Sep 18, 2018
Merged

Subscription concurrency #134

merged 20 commits into from
Sep 18, 2018

Conversation

slashdotdash
Copy link
Member

@slashdotdash slashdotdash commented Sep 1, 2018

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

👍

@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

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