Documentation ¶
Overview ¶
Package keyvalue contains a base implementation of much of the common logic required for a scale-out tablestore implementation of an event store. Each store driver need only support four methods, which can be passed via the keyvalue.Options structure:
CheckSequence // Check if a particular key/seq pair exists. FetchEvents // Fetch events forward from a particular sequence number PutEvents // Put a set of events into the store Close // Shut-down the driver
By abstracting store implementations down to this API, it's assumed it will be easier to add more providers later. Specific providers that suit this model include DynamoDB, Azure Tables, MongoDB, Cassandra - but the model will work for essentially any provider that has support for a dual-part unique key (Agg ID, Sequence) and supports range scans for these.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStore ¶
func NewStore(options Options) eventsourcing.EventStore
NewStore creates a new key-value store that provides a simple baseline set of event storage capabilities
Types ¶
type Event ¶
type Event struct { EventType eventsourcing.EventType `json:"type"` EventData interface{} `json:"data"` }
Event is a raw event within a key-value store.
type FetchCallback ¶
type FetchCallback func(key string, seq int64) ([]KeyedEvent, error)
FetchCallback is a function that describes the behaviour for fetching events from a key-value store. Typically this is a sequential crawl forward from the specified sequence for a partitioning key.
type KeyedEvent ¶
type KeyedEvent struct { Key string `json:"key"` Sequence int64 `json:"sequence"` EventType eventsourcing.EventType `json:"type"` EventData interface{} `json:"data"` }
KeyedEvent is an event with a key and sequence.
type Options ¶
type Options struct { CheckSequence SequenceExistsCallback // Check function to see if seq exists FetchEvents FetchCallback // Fetch events function PutEvents PutCallback // Put events function Close CloseCallback // Close callback }
Options is a structure containing the function callbacks required for a simple key-value store to be used as an event storage engine.
type PutCallback ¶
type PutCallback func(events []KeyedEvent) error
PutCallback is a function that puts events into the store.