memory

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventsStore

type EventsStore struct {

	// this is only useful for tests
	KeepRecordsAfterDisconnect bool
	// contains filtered or unexported fields
}

EventsStore keep in memory every journal NOTE: NOT RECOMMENDED FOR PRODUCTION CODE because all records are in memory and there is no durability. This is recommended for tests or PoC

func NewEventsStore

func NewEventsStore() *EventsStore

NewEventsStore creates a new instance of EventsStore

func (*EventsStore) Connect

func (s *EventsStore) Connect(ctx context.Context) error

Connect connects to the journal store

func (*EventsStore) DeleteEvents

func (s *EventsStore) DeleteEvents(ctx context.Context, persistenceID string, toSequenceNumber uint64) error

DeleteEvents deletes events from the store upt to a given sequence number (inclusive) FIXME: enhance the implementation. As it stands it may be a bit slow when there are a lot of records

func (*EventsStore) Disconnect

func (s *EventsStore) Disconnect(ctx context.Context) error

Disconnect disconnect the journal store

func (*EventsStore) GetLatestEvent

func (s *EventsStore) GetLatestEvent(ctx context.Context, persistenceID string) (*egopb.Event, error)

GetLatestEvent fetches the latest event

func (*EventsStore) GetShardEvents

func (s *EventsStore) GetShardEvents(ctx context.Context, shardNumber uint64, offset int64, max uint64) ([]*egopb.Event, int64, error)

GetShardEvents returns the next (max) events after the offset in the journal for a given shard

func (*EventsStore) PersistenceIDs

func (s *EventsStore) PersistenceIDs(ctx context.Context, pageSize uint64, pageToken string) (persistenceIDs []string, nextPageToken string, err error)

PersistenceIDs returns the distinct list of all the persistence ids in the journal store FIXME: enhance the implementation. As it stands it will be a bit slow when there are a lot of records

func (*EventsStore) Ping

func (s *EventsStore) Ping(ctx context.Context) error

Ping verifies a connection to the database is still alive, establishing a connection if necessary.

func (*EventsStore) ReplayEvents

func (s *EventsStore) ReplayEvents(ctx context.Context, persistenceID string, fromSequenceNumber, toSequenceNumber uint64, max uint64) ([]*egopb.Event, error)

ReplayEvents fetches events for a given persistence ID from a given sequence number(inclusive) to a given sequence number(inclusive)

func (*EventsStore) ShardNumbers

func (s *EventsStore) ShardNumbers(ctx context.Context) ([]uint64, error)

ShardNumbers returns the distinct list of all the shards in the journal store

func (*EventsStore) WriteEvents

func (s *EventsStore) WriteEvents(ctx context.Context, events []*egopb.Event) error

WriteEvents persist events in batches for a given persistenceID

Jump to

Keyboard shortcuts

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