brook v0.6.0 API Reference
Modules
Brook provides an event stream client interface for distributed applications to communicate indirectly and asynchronously. Brook sends and receives messages with the event stream (typically a message queue service) via a driver module and persists an application-specific view of the event stream via a storage module (defaulting to ETS).
Constructs a new Brook server config struct from a keyword list of inputs.
Defines the Brook Dispatcher behaviour, requiring the
init/0
and dispatch/1
functions be implemented by
the client.
Default implementation for the Brook.Dispatcher
Creates and joins a process group named :brook_servers
.
Ensures all members of the process group receive notification
of the received event by a member of the group.
Defines the behaviour clients must implement in order to send events to the event stream. Ensures a child specification is defined and a process can be started and linked to the calling process, as well as sending serialized events with an accompanying event type for pattern matching to handle different types of events from a single client event handling module.
Default implmentation of the Brook.Driver
behaviour.
Simply casts the event to the Brook server by way of a registry lookup.
Implements the Brook.Driver
behaviour for using Kafka
as the message bus underlying the event stream.
Implements the Elsa message handler behaviour for the Brook Kafka driver.
A driver for use in unit tests that will send any events sent by your application to your test process as messages in the format {:brook_event, %Brook.Event{} = event}
The Brook.Event
struct is the basic unit of message written to
and read from the event stream. It encodes the type of event (for
application event handlers to pattern match on), the author (source application),
The creation timestamp of the message, the actual data of the message,
and a boolean detailing if the message was forwarded within the Brook
Server process group.
Defines the Brook.Event.Handler
behaviour that an application
is expected to provide for processing events off the event stream via
Brook, as well as a default implementation.
An exception that is raised when no valid event can be found.
An exception that is raised when an instance of brook cannot be found.
Process event messages to and from the underlying event stream message bus implementation. Interact with the application's persisted view state of the event stream with getter and setter functions to write and update events from the view state as well as delete them.
Defines the Brook.Storage
behaviour that must be implemented by
storage driver processes. Starts a process and defines a child specification
for including the driver in Brook's supervision tree.
Implements the Brook.Storage
behaviour for ETS,
saving the application view state to the in-memory Erlang
key/value datastore.
Implements the Brook.Storage
behaviour for the Redis
key/value storage system, saving the application view state
as binary encodings of the direct Elixir terms to be saved with
maximum compression.
A Brook application supervisor, managing the process registry, storage and driver module processes, and the server process.
An exception that is raised when calls are made to retrieve values from the view state, but Brook is Uninitialized.