Packages

Elixir client for the Routemaster event bus server. Supports publishing events, subscribing to topics, receiving and processing events. Also incluses a HTTP client integrated with a builtin cache service.

Current section

Files

Jump to
routemaster_client lib routemaster drain example_app.ex
Raw

lib/routemaster/drain/example_app.ex

defmodule Routemaster.Drain.ExampleApp do
@moduledoc """
A Plug to receive events over HTTP.
This is just an example of how to build a Drain app, and was
built using the `Routemaster.Drain` module.
Please check the sourcecode for the details.
"""
use Routemaster.Drain
drain Routemaster.Drains.Siphon,
topic: "rabbits", to: Routemaster.ExampleRabbitSiphon
drain Routemaster.Drains.Dedup
drain Routemaster.Drains.IgnoreStale
drain Routemaster.Drains.FetchAndCache
drain Routemaster.Drains.Notify,
listener: Routemaster.ExampleListener,
only: ["llamas", "hedgehogs"]
end
defmodule Routemaster.ExampleListener do
@moduledoc false
require Logger
def call(events) do
Logger.info """
[#{__MODULE__}]: #{length(events)} events received:
#{inspect events}
"""
end
end
defmodule Routemaster.ExampleRabbitSiphon do
@moduledoc false
require Logger
def call(events) do
Logger.info """
[#{__MODULE__}]: #{length(events)} events siphoned:
#{inspect events}
"""
end
end