eventstore

package
v0.0.0-...-2d60b20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package eventstore handles the low level badger interactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateStats

type AggregateStats struct {
	LastId ulid.ULID
	Total  uint
}

type BadgerEventStore

type BadgerEventStore struct {
	RootDir                    string
	MemoryOnly                 bool
	EncryptionKey              []byte
	EncryptionRotationDuration time.Duration
	// contains filtered or unexported fields
}

func (*BadgerEventStore) Append

func (b *BadgerEventStore) Append(aggregate string, entity string, content interface{}) (*Tail, error)

func (*BadgerEventStore) Close

func (b *BadgerEventStore) Close() error

func (*BadgerEventStore) Read

func (b *BadgerEventStore) Read(aggregate string, entity string, factId string, maxCount int) (*RecordList, error)

func (*BadgerEventStore) Register

func (b *BadgerEventStore) Register(t interface{})

func (*BadgerEventStore) Scan

func (b *BadgerEventStore) Scan(aggregate string) (*EntityList, error)

func (*BadgerEventStore) Tail

func (b *BadgerEventStore) Tail(aggregate string, entity string) (*Tail, error)

type EntityList

type EntityList struct {
	List  []string
	Total uint
}

type EventStore

type EventStore interface {
	// Register a type for (de)serialization, needed to store and reconstitute objects
	Register(t interface{})
	// Append append an event to the event store for the fact
	Append(aggregate string, entity string, content interface{}) (*Tail, error)
	// Tail gets the last event id
	Tail(aggregate string, entity string) (*Tail, error)
	// Read the events for an aggregate from the identified event id
	Read(aggregate string, entity string, originEventId string, maxCount int) (*RecordList, error)
	// Scan will list all keys in the aggregate (excluding individual events)
	Scan(aggregate string) (*EntityList, error)
	// Close the event store
	Close() error
}

EventStore provides an interface to store events for a topic, and retrieve them later.

func EncryptedFileStore

func EncryptedFileStore(path string, key []byte, rotationDur time.Duration) EventStore

func FileStore

func FileStore(path string) EventStore

func MemoryStore

func MemoryStore() EventStore

type Fact

type Fact struct {
	Id        ulid.ULID
	Timestamp time.Time
	Content   interface{}
}

type IdGenerator

type IdGenerator interface {
	NewId(t time.Time) ulid.ULID
}

func NewIdGenerator

func NewIdGenerator() IdGenerator

type RecordList

type RecordList struct {
	List     []Fact
	Total    uint
	PageSize int
}

type Tail

type Tail struct {
	Fact  Fact
	Total uint
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL