postgres

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBHost     string // DBHost represents the database host
	DBPort     int    // DBPort is the database port
	DBName     string // DBName is the database name
	DBUser     string // DBUser is the database user used to connect
	DBPassword string // DBPassword is the database password
	DBSchema   string // DBSchema represents the database schema
}

Config defines the postgres events store configuration

type DurableStore

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

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

func NewStateStore

func NewStateStore(config *Config) *DurableStore

NewStateStore creates a new instance of StateStore

func (*DurableStore) Connect

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

Connect connects to the underlying postgres database

func (*DurableStore) Disconnect

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

Disconnect disconnects from the underlying postgres database

func (*DurableStore) GetLatestState

func (s *DurableStore) GetLatestState(ctx context.Context, persistenceID string) (*egopb.DurableState, error)

GetLatestState fetches the latest durable state of a persistenceID

func (*DurableStore) Ping

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

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

func (*DurableStore) WriteState

func (s *DurableStore) WriteState(ctx context.Context, state *egopb.DurableState) error

WriteState writes a durable state 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