Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminBoundaryDefinition added in v0.9.0

func AdminBoundaryDefinition(postgresConfig config.PostgresDBConfig, adminConfig config.AdminConfig) boundarymodel.Definition

func RunDbScripts

func RunDbScripts(db *sql.DB, boundary string, schema string, isAdminSchema bool, ctx context.Context) error

RunDbScripts initializes database tables for a specific boundary. It validates the boundary name, creates the schema if needed, and calls the PostgreSQL initialization functions to create boundary-prefixed tables.

Types

type BoundaryRegistry added in v0.8.0

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

BoundaryRegistry is the shared, concurrency-safe source for every PostgreSQL component that resolves boundary-specific SQL.

func NewBoundaryRegistry added in v0.8.0

func NewBoundaryRegistry(mappings map[string]config.BoundaryToPostgresSchemaMapping) *BoundaryRegistry

func (*BoundaryRegistry) Mappings added in v0.8.0

func (*BoundaryRegistry) Register added in v0.8.0

func (r *BoundaryRegistry) Register(boundary, schema string) error

type DatabaseRuntime added in v0.8.0

type DatabaseRuntime struct {
	SaveEvents        eventstore.EventsSaver
	GetEvents         eventstore.EventsRetriever
	LockProvider      eventstore.LockProvider
	AdminDB           common.DB
	Listener          *PGNotifyListener
	ProvisionBoundary func(context.Context, boundarymodel.Definition) error
	InstallBoundary   func(context.Context, boundarymodel.Definition) error
}

func InitializePostgresDatabaseRuntime added in v0.8.0

func InitializePostgresDatabaseRuntime(
	ctx context.Context,
	postgresDBConfig config.PostgresDBConfig,
	adminConfig config.AdminConfig,
	js jetstream.JetStream,
	logger logging.Logger,
) *DatabaseRuntime

type PGNotifyListener

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

func NewPGNotifyListener

func NewPGNotifyListener(
	ctx context.Context,
	connStr string,
	boundarySchemaMapping map[string]config.BoundaryToPostgresSchemaMapping,
	logger logging.Logger,
) (*PGNotifyListener, error)

func (*PGNotifyListener) Close

func (l *PGNotifyListener) Close(ctx context.Context)

Close waits for the Start goroutine to stop (it closes the connection on exit). The caller must cancel the context passed to Start to trigger shutdown; Close itself returns once Start has finished or ctx is done.

func (*PGNotifyListener) EnsureBoundary added in v0.8.0

func (l *PGNotifyListener) EnsureBoundary(ctx context.Context, boundary string) error

EnsureBoundary installs LISTEN routing for a boundary on the listener-owned connection. It wakes WaitForNotification instead of using pgx.Conn concurrently.

func (*PGNotifyListener) Signal

func (l *PGNotifyListener) Signal(boundary string) orisun.EventSignal

func (*PGNotifyListener) Start

func (l *PGNotifyListener) Start(ctx context.Context)

Start owns l.conn exclusively for the lifetime of the goroutine: it is the only place the connection is read, swapped (via reconnect), or closed. No other goroutine may touch l.conn — pgx.Conn is not safe for concurrent use.

type PostgresAdminDB

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

func NewPostgresAdminDB

func NewPostgresAdminDB(db *sql.DB, logger logging.Logger, schema string, boundary string, boundarySchemaMappings map[string]config.BoundaryToPostgresSchemaMapping) *PostgresAdminDB

func NewPostgresAdminDBWithRegistry added in v0.8.0

func NewPostgresAdminDBWithRegistry(db *sql.DB, logger logging.Logger, schema string, boundary string, registry *BoundaryRegistry) *PostgresAdminDB

func (*PostgresAdminDB) CreateBoundaryIndex

func (db *PostgresAdminDB) CreateBoundaryIndex(
	ctx context.Context,
	boundary, name string,
	fields []eventstore.BoundaryIndexField,
	conditions []eventstore.BoundaryIndexCondition,
	combinator string,
) error

func (*PostgresAdminDB) DeleteUser

func (p *PostgresAdminDB) DeleteUser(ctx context.Context, id string) error

func (*PostgresAdminDB) DropBoundaryIndex

func (db *PostgresAdminDB) DropBoundaryIndex(
	ctx context.Context,
	boundary, name string,
) error

func (*PostgresAdminDB) GetBoundaryIndex added in v0.9.3

func (db *PostgresAdminDB) GetBoundaryIndex(ctx context.Context, boundary, name string) (*eventstore.BoundaryIndex, error)

func (*PostgresAdminDB) GetEventsCount

func (s *PostgresAdminDB) GetEventsCount(ctx context.Context, boundary string) (int, error)

func (*PostgresAdminDB) GetProjectorLastPosition

func (s *PostgresAdminDB) GetProjectorLastPosition(ctx context.Context, projectorName string) (*eventstore.Position, error)

func (*PostgresAdminDB) GetUserById

func (s *PostgresAdminDB) GetUserById(ctx context.Context, id string) (eventstore.User, error)

func (*PostgresAdminDB) GetUserByUsername

func (s *PostgresAdminDB) GetUserByUsername(ctx context.Context, username string) (eventstore.User, error)

func (*PostgresAdminDB) GetUsersCount

func (s *PostgresAdminDB) GetUsersCount(ctx context.Context) (uint32, error)

func (*PostgresAdminDB) ListAdminUsers

func (s *PostgresAdminDB) ListAdminUsers(ctx context.Context) ([]*eventstore.User, error)

func (*PostgresAdminDB) ListBoundaryIndexes added in v0.9.3

func (db *PostgresAdminDB) ListBoundaryIndexes(ctx context.Context, boundary string) ([]eventstore.BoundaryIndex, error)

func (*PostgresAdminDB) SaveEventCount

func (s *PostgresAdminDB) SaveEventCount(ctx context.Context, event_count int, boundary string) error

func (*PostgresAdminDB) SaveUsersCount

func (s *PostgresAdminDB) SaveUsersCount(ctx context.Context, users_count uint32) error

func (*PostgresAdminDB) UpdateProjectorPosition

func (p *PostgresAdminDB) UpdateProjectorPosition(ctx context.Context, name string, position *eventstore.Position) error

func (*PostgresAdminDB) UpsertUser

func (s *PostgresAdminDB) UpsertUser(ctx context.Context, user eventstore.User) error

type PostgresBoundaryProvisioner added in v0.8.0

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

PostgresBoundaryProvisioner is the PostgreSQL adapter for the boundary_provisioning slice's ProvisionBoundary function port.

func NewPostgresBoundaryProvisioner added in v0.8.0

func NewPostgresBoundaryProvisioner(db *sql.DB, registry *BoundaryRegistry) *PostgresBoundaryProvisioner

func (*PostgresBoundaryProvisioner) InstallBoundary added in v0.8.0

func (p *PostgresBoundaryProvisioner) InstallBoundary(ctx context.Context, definition boundarymodel.Definition) error

InstallBoundary brings an already-provisioned boundary up to the schema version required by this process, then registers it in the boundary-aware SQL adapters. This is required for catalog boundaries discovered during startup: their physical schema may have been created by an older Orisun version.

func (*PostgresBoundaryProvisioner) ProvisionBoundary added in v0.8.0

func (p *PostgresBoundaryProvisioner) ProvisionBoundary(ctx context.Context, definition boundarymodel.Definition) error

ProvisionBoundary validates and creates the physical PostgreSQL boundary. Cluster coordination ensures only one server process performs this work.

type PostgresGetEvents

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

func NewPostgresGetEvents

func NewPostgresGetEvents(db *sql.DB, logger logging.Logger,
	boundarySchemaMappings map[string]config.BoundaryToPostgresSchemaMapping) *PostgresGetEvents

func NewPostgresGetEventsWithRegistry added in v0.8.0

func NewPostgresGetEventsWithRegistry(db *sql.DB, logger logging.Logger, registry *BoundaryRegistry) *PostgresGetEvents

func (*PostgresGetEvents) GetBatch

func (*PostgresGetEvents) GetLatestByCriteria

GetLatestByCriteria returns the latest event per criterion plus the latest position of the complete OR query. The per-criterion lookups run inside one SQL statement (get_latest_by_criteria_v2 builds a UNION ALL of LIMIT-1 subqueries), so all returned carried state comes from one snapshot.

func (*PostgresGetEvents) GetWriteContext added in v0.12.0

func (*PostgresGetEvents) Schema

func (s *PostgresGetEvents) Schema(boundary string) (string, error)

type PostgresSaveEvents

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

func NewPostgresSaveEvents

func NewPostgresSaveEvents(
	ctx context.Context,
	db *sql.DB,
	logger logging.Logger,
	boundarySchemaMappings map[string]config.BoundaryToPostgresSchemaMapping) *PostgresSaveEvents

func NewPostgresSaveEventsWithConfig added in v0.10.0

func NewPostgresSaveEventsWithConfig(
	ctx context.Context,
	db *sql.DB,
	logger logging.Logger,
	boundarySchemaMappings map[string]config.BoundaryToPostgresSchemaMapping,
	gcCfg config.PostgresGroupCommitConfig,
) (*PostgresSaveEvents, error)

func NewPostgresSaveEventsWithRegistry added in v0.8.0

func NewPostgresSaveEventsWithRegistry(ctx context.Context, db *sql.DB, logger logging.Logger, registry *BoundaryRegistry) *PostgresSaveEvents

func (*PostgresSaveEvents) SavePrepared

func (s *PostgresSaveEvents) SavePrepared(
	ctx context.Context,
	events eventstore.PreparedEventBatch,
	boundary string,
	consistency []eventstore.ConsistencyCheck,
) (transactionID string, globalID int64, err error)

func (*PostgresSaveEvents) Schema

func (s *PostgresSaveEvents) Schema(boundary string) (string, error)

Jump to

Keyboard shortcuts

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