event_bus v1.0.0-beta1 EventBus
Simple event bus implementation.
Link to this section Summary
Functions
Fetch event data
Send the event processing completed to the watcher
Send the event processing skipped to the watcher
Send event to all listeners
Register a topic
Subscribe to the bus
List the subscribers to the bus
List the subscribers to the bus with given event name
Check if topic registered
List all registered topics
Unregister a topic
Unsubscribe from the bus
Link to this section Functions
Send the event processing completed to the watcher
Examples
EventBus.mark_as_completed({MyEventListener, :hello_received, "123"})
Send the event processing skipped to the watcher
Examples
EventBus.mark_as_skipped({MyEventListener, :unmatched_occurred, "124"})
# For configurable listeners you must pass tuple of processor and config
my_config = %{}
listener = {OtherListener, my_config}
EventBus.mark_as_skipped({listener, :unmatched_occurred, "124"})
:ok
Send event to all listeners.
Examples
event = %Event{id: 1, topic: :webhook_received,
data: %{"message" => "Hi all!"}}
EventBus.notify(event)
:ok
Subscribe to the bus.
Examples
EventBus.subscribe({MyEventListener, [".*"]})
:ok
# For configurable listeners you can pass tuple of processor and config
my_config = %{}
EventBus.subscribe({{OtherListener, my_config}, [".*"]})
:ok
List the subscribers to the bus.
Examples
EventBus.subscribers()
[MyEventListener]
# One usual and one configured listener with its config
EventBus.subscribers()
[MyEventListener, {OtherListener, %{}}]
List the subscribers to the bus with given event name.
Examples
EventBus.subscribers(:metrics_received)
[MyEventListener]
# One usual and one configured listener with its config
EventBus.subscribers(:metrics_received)
[MyEventListener, {OtherListener, %{}}]