Documentation
¶
Index ¶
- Constants
- Variables
- func GetEventStream(message AggregateMessage) string
- func GetStream(aggregateType, aggregateID string) string
- func NewRecordIterator(recordResult <-chan ResultRecord) *recordIterator
- func NewRecordIteratorWithError(err error) *recordIterator
- func ParseStream(streamName string) (aggregateType, aggregateID string)
- func PublishRecordOrCancel(ctx context.Context, resultRecords chan ResultRecord, record *Record, ...) bool
- type AggregateMessage
- type Event
- type EventBinder
- type EventRecord
- type EventTypeIdentifier
- type Record
- type RecordIoStream
- type RecordIterator
- type RecordSerializer
- type RecordSubscriber
- type RecordSubscriberFunc
- type RecordSubscription
- type ResultRecord
- type Store
Constants ¶
const Version = "0.12.0"
Version for RangeDB.
Variables ¶
var ErrStreamNotFound = fmt.Errorf("stream not found")
Functions ¶
func GetEventStream ¶
func GetEventStream(message AggregateMessage) string
GetEventStream returns the stream name for an event.
func NewRecordIterator ¶ added in v0.6.0
func NewRecordIterator(recordResult <-chan ResultRecord) *recordIterator
NewRecordIterator constructs a new rangedb.Record iterator
func NewRecordIteratorWithError ¶ added in v0.12.0
func NewRecordIteratorWithError(err error) *recordIterator
func ParseStream ¶ added in v0.4.0
ParseStream returns the aggregateType and aggregateID for a stream name.
func PublishRecordOrCancel ¶ added in v0.6.0
func PublishRecordOrCancel(ctx context.Context, resultRecords chan ResultRecord, record *Record, timeout time.Duration) bool
PublishRecordOrCancel publishes a Record to a ResultRecord channel, or times out.
Types ¶
type AggregateMessage ¶
AggregateMessage is the interface that supports building an event stream name.
type Event ¶
type Event interface {
AggregateMessage
EventType() string
}
Event is the interface that defines the required event methods.
func NewRawEvent ¶ added in v0.5.0
NewRawEvent constructs a new raw event when an event struct is unavailable or unknown.
type EventBinder ¶ added in v0.2.4
type EventBinder interface {
Bind(events ...Event)
}
EventBinder defines how to bind events for serialization.
type EventRecord ¶ added in v0.5.0
type EventRecord struct {
Event Event
Metadata interface{}
}
EventRecord stores the event and metadata to be used for persisting.
type EventTypeIdentifier ¶ added in v0.3.0
EventTypeIdentifier is the interface for retrieving an event type.
type Record ¶
type Record struct {
AggregateType string `msgpack:"a" json:"aggregateType"`
AggregateID string `msgpack:"i" json:"aggregateID"`
GlobalSequenceNumber uint64 `msgpack:"g" json:"globalSequenceNumber"`
StreamSequenceNumber uint64 `msgpack:"s" json:"streamSequenceNumber"`
InsertTimestamp uint64 `msgpack:"u" json:"insertTimestamp"`
EventID string `msgpack:"e" json:"eventID"`
EventType string `msgpack:"t" json:"eventType"`
Data interface{} `msgpack:"d" json:"data"`
Metadata interface{} `msgpack:"m" json:"metadata"`
}
Record contains event data and metadata.
func ReadNRecords ¶ added in v0.3.0
func ReadNRecords(totalEvents uint64, f func() (RecordIterator, context.CancelFunc)) []*Record
ReadNRecords reads up to N records from the channel returned by f into a slice
type RecordIoStream ¶
type RecordIoStream interface {
Read(io.Reader) RecordIterator
Write(io.Writer, RecordIterator) <-chan error
Bind(events ...Event)
}
RecordIoStream is the interface that (de)serializes a stream of Records.
type RecordIterator ¶ added in v0.6.0
RecordIterator is used to traverse a stream of record events.
func MergeRecordIteratorsInOrder ¶ added in v0.6.0
func MergeRecordIteratorsInOrder(recordIterators []RecordIterator) RecordIterator
MergeRecordIteratorsInOrder combines record channels ordered by record.GlobalSequenceNumber.
type RecordSerializer ¶
type RecordSerializer interface {
Serialize(record *Record) ([]byte, error)
Deserialize(data []byte) (*Record, error)
Bind(events ...Event)
}
RecordSerializer is the interface that (de)serializes Records.
type RecordSubscriber ¶
type RecordSubscriber interface {
Accept(record *Record)
}
RecordSubscriber is the interface that defines how a projection receives Records.
type RecordSubscriberFunc ¶ added in v0.3.0
type RecordSubscriberFunc func(*Record)
The RecordSubscriberFunc type is an adapter to allow the use of ordinary functions as record subscribers. If f is a function with the appropriate signature, RecordSubscriberFunc(f) is a Handler that calls f.
func (RecordSubscriberFunc) Accept ¶ added in v0.3.0
func (f RecordSubscriberFunc) Accept(record *Record)
Accept receives a record.
type RecordSubscription ¶ added in v0.7.0
type RecordSubscription interface {
// Start returns immediately after subscribing only to new events in a goroutine.
Start() error
// StartFrom blocks until all previous events have been processed, then returns after subscribing to new events in a goroutine.
StartFrom(globalSequenceNumber uint64) error
// Stop cancels the subscription and stops.
Stop()
}
RecordSubscription defines how a subscription starts and stops.
type ResultRecord ¶ added in v0.6.0
ResultRecord combines Record and error as a result struct for event queries.
type Store ¶
type Store interface {
EventBinder
// Events returns a RecordIterator containing all events in the store starting with globalSequenceNumber.
Events(ctx context.Context, globalSequenceNumber uint64) RecordIterator
// EventsByAggregateTypes returns a RecordIterator containing all events for each aggregateType(s) starting
// with globalSequenceNumber.
EventsByAggregateTypes(ctx context.Context, globalSequenceNumber uint64, aggregateTypes ...string) RecordIterator
// EventsByStream returns a RecordIterator containing all events in the stream starting with streamSequenceNumber.
EventsByStream(ctx context.Context, streamSequenceNumber uint64, streamName string) RecordIterator
// OptimisticDeleteStream removes an entire stream. If the expectedStreamSequenceNumber does not match the current
// stream sequence number, an rangedberror.UnexpectedSequenceNumber error is returned.
OptimisticDeleteStream(ctx context.Context, expectedStreamSequenceNumber uint64, streamName string) error
// OptimisticSave persists events to a single stream returning the new StreamSequenceNumber or an error. If
// the expectedStreamSequenceNumber does not match the current stream sequence number,
// an rangedberror.UnexpectedSequenceNumber error is returned.
OptimisticSave(ctx context.Context, expectedStreamSequenceNumber uint64, eventRecords ...*EventRecord) (uint64, error)
// Save persists events to a single stream returning the new StreamSequenceNumber or an error.
Save(ctx context.Context, eventRecords ...*EventRecord) (uint64, error)
AllEventsSubscription(ctx context.Context, bufferSize int, subscriber RecordSubscriber) RecordSubscription
AggregateTypesSubscription(ctx context.Context, bufferSize int, subscriber RecordSubscriber, aggregateTypes ...string) RecordSubscription
TotalEventsInStream(ctx context.Context, streamName string) (uint64, error)
}
Store is the interface that stores and retrieves event records.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gen-random-events
command
|
|
|
grpc-event-subscriber
command
|
|
|
rangedb
command
|
|
|
ws-event-subscriber
command
|
|
|
examples
|
|
|
chat
Code generated by go generate; DO NOT EDIT.
|
Code generated by go generate; DO NOT EDIT. |
|
gen
|
|
|
aggregategenerator
command
|
|
|
commandgenerator
command
|
|
|
eventbinder
command
|
|
|
eventgenerator
command
|
|
|
pkg
|
|
|
crypto/cryptotest
Code generated by go generate; DO NOT EDIT.
|
Code generated by go generate; DO NOT EDIT. |
|
rangedbui/gen/pack-templates
command
|
|
|
provider
|
|
|
Code generated by go generate; DO NOT EDIT.
|
Code generated by go generate; DO NOT EDIT. |
|
cmd/random-data
command
|
