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

Conversation

Projects
None yet
2 participants
@slashdotdash
Copy link
Member

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 Sep 2, 2018

@ababushkin

This comment has been minimized.

Copy link

ababushkin commented Sep 8, 2018

👍

@slashdotdash slashdotdash force-pushed the feature/concurrency branch from 53c1b86 to 4690ca6 Sep 17, 2018

@slashdotdash slashdotdash force-pushed the feature/concurrency branch from 4690ca6 to a06bc3e Sep 17, 2018

@slashdotdash slashdotdash force-pushed the feature/concurrency branch from 466eecf to d971424 Sep 17, 2018

slashdotdash added some commits Sep 17, 2018

Fix failing tests on Travis CI
Due to not waiting for subscriber process to terminate in test.

@slashdotdash slashdotdash merged commit 02e1583 into master Sep 18, 2018

1 check passed

continuous-integration/travis-ci/push The Travis CI build passed
Details

@slashdotdash slashdotdash deleted the feature/concurrency branch Sep 18, 2018

@ababushkin

This comment has been minimized.

Copy link

ababushkin commented Sep 19, 2018

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

renanlage added 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