Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory implementation for managing and storing histories. It uses a map to associate aggregate IDs with their corresponding histories, and a mutex to ensure thread-safe operations.
func New ¶
func New(snapshotInterval int32) *MemoryStore
New initializes and returns a new instance of MemoryStore. Pass the aggregate's snapshot interval (0 to disable snapshots).
func (*MemoryStore) Load ¶
Load retrieves the history for a given aggregate ID. If the context is canceled or timed out, it returns an error. The function uses read locks for thread-safe read access to the `events` map.
func (*MemoryStore) Save ¶
func (m *MemoryStore) Save(ctx context.Context, aggregateId string, records ...*recordv1.Record) error
Save stores a list of records for a given aggregate ID. If the context is canceled or timed out, it returns an error. The function uses write locks for thread-safe access to the `events` map.
func (*MemoryStore) SnapshotInterval ¶
func (m *MemoryStore) SnapshotInterval() int32
SnapshotInterval returns the snapshot interval (0 means disabled).