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

Use PostgreSQL's NOTIFY/LISTEN for event pub/sub #100

Merged
merged 8 commits into from
Jan 21, 2018

Conversation

slashdotdash
Copy link
Member

@slashdotdash slashdotdash commented Jan 9, 2018

Using PostgreSQL for pub/sub removes the requirement for EventStore to form a cluster of nodes.

It can be used on a single node or multiple nodes, but they don't need to be directly connected. The database will be used to distribute events instead. This simplifies running EventStore on a cluster and removes the dependency upon Swarm.

A single listener process subscribes to event notifications using PostgreSQL's LISTEN command. Whenever events are appended to storage a NOTIFY command is executed by a table trigger. The notification payload contains the first and last event number of the appended events (e.g. 1,2). These events are then read from storage and published to interested subscribers. Elixir's GenStage is used to read and forward events to subscriptions.

PG2 groups are now used for event pub/sub when run in distributed mode.

slashdotdash added a commit that referenced this pull request Jan 11, 2018
@slashdotdash slashdotdash force-pushed the feature/listen-notify branch 2 times, most recently from 8a7383c to 9df1755 Compare January 11, 2018 13:43
slashdotdash added a commit that referenced this pull request Jan 11, 2018
Using PostgreSQL for pub/sub removes need for EventStore to form a cluster of nodes. It can be used on a single node, or multiple nodes, but they don't need to be directly connected. Instead the database will be used to distribute events. This simplifies running EventStore on a cluster.
Listener module is now a cluster singleton so only one PostgreSQL `LISTEN` connection is used per event store cluster.
Create PostgreSQL connection for notify test.
Allow short delay for distributed subscription tests.
Increase assert receive and refute timeouts in `distributed` env.
Use latest Elixir and Erlang versions in Travis CI config.
Use default logger format in test envs.
Additional subscription logging to help identify intermittent test failure in `:distributed` env.
@slashdotdash slashdotdash merged commit 8e6665a into master Jan 21, 2018
@slashdotdash slashdotdash deleted the feature/listen-notify branch January 21, 2018 13:46
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.

1 participant