Jumar.EventBus.Consumer behaviour (Jumar v0.1.0)
View SourceA GenStage ConsumerSupervisor implementation to consume events
from Jumar.EventBus.Producer
.
Usage
defmodule MyConsumer do
use Jumar.EventBus.Consumer,
producers: [MyProducer]
def handle_event(event) do
IO.inspect(event)
end
end
You can also specify multiple producers to subscribe to, as well as all other
options available in ConsumerSupervisor
.
defmodule MyConsumer do
use Jumar.EventBus.Consumer,
producers: [
{MyProducer, min_demand: 1, max_demand: 50},
{AnotherProducer, max_demand: 200}
]
def handle_event(event) do
IO.inspect(event)
end
end
See the ConsumerSupervisor
module documentation on producers for more options.
Summary
Functions
Starts the consumer.
Callbacks
@callback handle_event(Jumar.EventBus.Event.t()) :: :ok
@callback handle_failure(Jumar.EventBus.Event.t(), [{:error, any()}]) :: :ok