Documentation ¶
Overview ¶
Deals with persisting events to disk and querying them. No network is involved in any of the code in this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { // The name of the stream to which this event shall be stored. Stream StreamName // The data that is to be stored for this event. Can be an // arbitrary byte slice. Data []byte }
An event that has not yet been persisted to disk.
type EventStore ¶
type EventStore struct {
// contains filtered or unexported fields
}
Instance of an event store. All of its functions are threadsafe.
func (*EventStore) Add ¶
func (v *EventStore) Add(event Event) (EventId, error)
Store an event to the event store. Returns the unique event id that the event was stored under. As long as no error occurred, of course.
func (*EventStore) ListStreams ¶
func (v *EventStore) ListStreams(start StreamName, maxItems int) chan StreamName
List the available streams through a stream.
func (*EventStore) Query ¶
func (v *EventStore) Query(req QueryRequest) (chan StoredEvent, error)
Query events from an event store. If the request is malformed in any way, an error is returned. Otherwise, the query result is streamed through the res channel in chronological order.
Currently this function will make error checks synchronously. If all looks good, streaming the results through `res` is done asynchronously.
TODO: Also make the error checking asynchronously, to minimize IO blocking when calling this function.
func (*EventStore) RegisterPublishedEventsChannel ¶
func (v *EventStore) RegisterPublishedEventsChannel(publisher chan StoredEvent)
Register a channel where are published events will be pushed to. Multiple channels can be registered.
type QueryRequest ¶
A query request.
type StoredEvent ¶
type StoredEvent struct { // The ID for the stored event. No other event exists with name // Stream and ID Id. Id EventId // The event that was persisted. Event }
An event that has previously been persisted to disk.