postgres

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 14 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 {
	// contains filtered or unexported fields
}

EventsStore implements the EventsStore interface and helps persist events in a Postgres database

func NewEventsStore

func NewEventsStore(config *postgres.Config) *EventsStore

NewEventsStore creates a new instance of PostgresEventStore

func (*EventsStore) Connect

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

Connect connects to the underlying postgres database

func (*EventsStore) DeleteEvents

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

DeleteEvents deletes events from the postgres up to a given sequence number (inclusive)

func (*EventsStore) Disconnect

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

Disconnect disconnects from the underlying postgres database

func (*EventsStore) GetLatestEvent

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

GetLatestEvent fetches the latest event

func (*EventsStore) GetShardEvents added in v1.1.0

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

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 added in v1.1.0

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 writes a bunch of events into the underlying postgres database

type SchemaUtils

type SchemaUtils struct {
	// contains filtered or unexported fields
}

SchemaUtils help create the various test tables in unit/integration tests

func NewSchemaUtils

func NewSchemaUtils(db *postgres.TestDB) *SchemaUtils

NewSchemaUtils creates an instance of SchemaUtils

func (SchemaUtils) CreateTable

func (d SchemaUtils) CreateTable(ctx context.Context) error

CreateTable creates the event store table used for unit tests

func (SchemaUtils) DropTable

func (d SchemaUtils) DropTable(ctx context.Context) error

DropTable drop the table used in unit test This is useful for resource cleanup after a unit test

Jump to

Keyboard shortcuts

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