otobus / event_bus

:surfer: Traceable, extendable and minimalist **event bus** implementation for Elixir with built-in **event store** and **event watcher** based on ETS.

Home Page:https://hexdocs.pm/event_bus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clustered events

hassox opened this issue · comments

Hi,

This is a question more than an issue.

  • Is it possible to run the event bus in a clustered environment?
  • If yes, is it possible to provide each event only once to a subscriber module globally?

I read through the docs but unfortunately this wasn't clear from them.

👋

It is possible but the library doesn’t bring any helper for that purpose(Even though the main intention to create this library is to use for internal module communications, it is possible to deliver events across nodes.). It depends on the developer to choose what technique to use. For the simplest case: you can apply all Erlang/Elixir techniques to achieve that. For example:

for node <- Node.list() do
  Node.spawn(node, EventBus, :register_topic, [:checkout_completed])
  Node.spawn(node, EventBus, :notify, [%{EventBus.Model.Event{..}}])
end

Or you can use built-in pg2...

If you have time, I recommmend to use a consensus protocol like Raft or Paxos to achieve only one consumer to pick specific topic queue. If you don’t have time Redis Streams, Apache Kafka or RabbitMQ would be good choice instead of EventBus.