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

Support distributed dispatch consistency #135

Merged
merged 5 commits into from
Feb 3, 2018

Conversation

slashdotdash
Copy link
Member

@slashdotdash slashdotdash commented Feb 2, 2018

Allow strongly consistent command dispatch to work when Commanded is run on multiple nodes, but not formed as a cluster.

Phoenix's pub/sub library is optionally used since it supports broadcasting messages and tracking presence using PG2 or Redis. The Redis adapter can be used when running multiple nodes that are not connected together.

Usage

The new Commanded.PubSub behaviour defines basic pub/sub and process tracking functions. The default implementation uses Elixir's local-only Registry module.

# `config/config.exs`
config :commanded, pubsub: :local

To use Phoenix pub/sub you must add it to your project's depedencies in mix.exs:

defp deps do
  [
    {:phoenix_pubsub, "~> 1.0"}
  ]
end

Then configure the Phoenix pub/sub adapter you'd like to use:

# `config/config.exs`
config :commanded, pubsub: [
  phoenix_pubsub: [
    adapter: Phoenix.PubSub.PG2,
    pool_size: 1
  ]
]

The available options are:

  • Phoenix.PubSub.PG2 - uses Distributed Elixir, directly exchanging notifications between servers
  • Phoenix.PubSub.Redis - uses Redis to exchange data between servers

Used for dispatch with strong consistency for subscription ack's.

Initial implementation uses Elixir's `Registry` module for local node usage only.

An adapter using Phoenix PubSub[1] will be provided for multi-node deployments.

[1] https://hex.pm/packages/phoenix_pubsub
To prevent clashes between pub/sub and tracking topics.
@slashdotdash slashdotdash merged commit 00b6db3 into master Feb 3, 2018
@slashdotdash slashdotdash deleted the feature/dispatch-consistency branch February 3, 2018 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant