eventstore v0.2.0 EventStore
EventStore process to read and write events to a logical event stream
Example usage
# ensure the event store application has been started
Application.ensure_all_started(:eventstore)
# append events to a stream
{:ok, persisted_events} = EventStore.append_to_stream(stream_uuid, expected_version, events)
# read all events from a stream, starting at the beginning
{:ok, recorded_events} = EventStore.read_stream_forward(stream_uuid)
Summary
Functions
Append one or more events to a stream atomically
Reads the requested number of events from the given stream, in the order in which they were originally written
Subscriber will be notified of each event persisted to any stream
Subscriber will be notified of each event persisted to a single stream
Unsubscribe an existing subscriber from event notifications
Functions
Append one or more events to a stream atomically.
stream_uuidis used to uniquely identify a stream.expected_versionis used for optimistic concurrency. Specify 0 for the creation of a new stream. An{:error, wrong_expected_version}response will be returned if the stream already exists. Any positive number will be used to ensure you can only append to the stream if it is at exactly that version.eventsis a list of%EventStore.EventData{}structs EventStore does not have any built-in serialization. The payload and headers for each event should already be serialized to binary data before appending to the stream.
Reads the requested number of events from the given stream, in the order in which they were originally written.
stream_uuidis used to uniquely identify a stream.start_versionoptionally, the version number of the first event to read. Defaults to the beginning of the stream if not set.countoptionally, the maximum number of events to read. If not set it will return all events from the stream.
Subscriber will be notified of each event persisted to any stream.
subscription_nameis used to name the subscription group.subscriberis a process that will receive{:event, event}callback messages.
Returns {:ok, subscription} when subscription succeeds.
Subscriber will be notified of each event persisted to a single stream.
stream_uuidis the stream to subscribe to. Use the$allidentifier to subscribe to events from all streams.subscription_nameis used to name the subscription group.subscriberis a process that will receive{:event, event}callback messages.
Returns {:ok, subscription} when subscription succeeds.
Unsubscribe an existing subscriber from event notifications.
stream_uuidis the stream to subscribe to. Use the$allidentifier to subscribe to events from all streams.subscription_nameis used to name the subscription group.subscriberis a process that will receive{:event, event}callback messages.
Returns :ok on success.