Documentation
¶
Index ¶
- func AdminBoundaryDefinition(postgresConfig config.PostgresDBConfig, adminConfig config.AdminConfig) boundarymodel.Definition
- func RunDbScripts(db *sql.DB, boundary string, schema string, isAdminSchema bool, ...) error
- type BoundaryRegistry
- type DatabaseRuntime
- type PGNotifyListener
- type PostgresAdminDB
- func (db *PostgresAdminDB) CreateBoundaryIndex(ctx context.Context, boundary, name string, ...) error
- func (p *PostgresAdminDB) DeleteUser(ctx context.Context, id string) error
- func (db *PostgresAdminDB) DropBoundaryIndex(ctx context.Context, boundary, name string) error
- func (db *PostgresAdminDB) GetBoundaryIndex(ctx context.Context, boundary, name string) (*eventstore.BoundaryIndex, error)
- func (s *PostgresAdminDB) GetEventsCount(ctx context.Context, boundary string) (int, error)
- func (s *PostgresAdminDB) GetProjectorLastPosition(ctx context.Context, projectorName string) (*eventstore.Position, error)
- func (s *PostgresAdminDB) GetUserById(ctx context.Context, id string) (eventstore.User, error)
- func (s *PostgresAdminDB) GetUserByUsername(ctx context.Context, username string) (eventstore.User, error)
- func (s *PostgresAdminDB) GetUsersCount(ctx context.Context) (uint32, error)
- func (s *PostgresAdminDB) ListAdminUsers(ctx context.Context) ([]*eventstore.User, error)
- func (db *PostgresAdminDB) ListBoundaryIndexes(ctx context.Context, boundary string) ([]eventstore.BoundaryIndex, error)
- func (s *PostgresAdminDB) SaveEventCount(ctx context.Context, event_count int, boundary string) error
- func (s *PostgresAdminDB) SaveUsersCount(ctx context.Context, users_count uint32) error
- func (p *PostgresAdminDB) UpdateProjectorPosition(ctx context.Context, name string, position *eventstore.Position) error
- func (s *PostgresAdminDB) UpsertUser(ctx context.Context, user eventstore.User) error
- type PostgresBoundaryProvisioner
- type PostgresEventPublishing
- func (s *PostgresEventPublishing) GetLastPublishedEventPosition(ctx context.Context, boundary string) (orisun.Position, error)
- func (s *PostgresEventPublishing) InsertLastPublishedEvent(ctx context.Context, boundaryOfInterest string, transactionId int64, ...) error
- func (s *PostgresEventPublishing) Schema(boundary string) (string, error)
- type PostgresGetEvents
- func (s *PostgresGetEvents) GetBatch(ctx context.Context, req *eventstore.GetEventsRequest) (eventstore.ReadEventBatch, error)
- func (s *PostgresGetEvents) GetLatestByCriteria(ctx context.Context, query eventstore.LatestByCriteriaQuery) (eventstore.LatestByCriteriaBatch, error)
- func (s *PostgresGetEvents) Schema(boundary string) (string, error)
- type PostgresSaveEvents
- func NewPostgresSaveEvents(ctx context.Context, db *sql.DB, logger logging.Logger, ...) *PostgresSaveEvents
- func NewPostgresSaveEventsWithConfig(ctx context.Context, db *sql.DB, logger logging.Logger, ...) (*PostgresSaveEvents, error)
- func NewPostgresSaveEventsWithRegistry(ctx context.Context, db *sql.DB, logger logging.Logger, ...) *PostgresSaveEvents
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 (r *BoundaryRegistry) Mappings() map[string]config.BoundaryToPostgresSchemaMapping
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
EventPublishing eventstore.EventPublishingTracker
Listener *PGNotifyListener
ProvisionBoundary func(context.Context, boundarymodel.Definition) error
InstallBoundary func(context.Context, boundarymodel.Definition) error
PreexistingAdminStore bool
}
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, catchupInterval time.Duration) 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 (*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 (*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 PostgresEventPublishing ¶
type PostgresEventPublishing struct {
// contains filtered or unexported fields
}
func NewPostgresEventPublishing ¶
func NewPostgresEventPublishing(db *sql.DB, logger logging.Logger, boundarySchemaMappings map[string]config.BoundaryToPostgresSchemaMapping) *PostgresEventPublishing
func NewPostgresEventPublishingWithRegistry ¶ added in v0.8.0
func NewPostgresEventPublishingWithRegistry(db *sql.DB, logger logging.Logger, registry *BoundaryRegistry) *PostgresEventPublishing
func (*PostgresEventPublishing) GetLastPublishedEventPosition ¶
func (*PostgresEventPublishing) InsertLastPublishedEvent ¶
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 (s *PostgresGetEvents) GetBatch(ctx context.Context, req *eventstore.GetEventsRequest) (eventstore.ReadEventBatch, error)
func (*PostgresGetEvents) GetLatestByCriteria ¶
func (s *PostgresGetEvents) GetLatestByCriteria(ctx context.Context, query eventstore.LatestByCriteriaQuery) (eventstore.LatestByCriteriaBatch, error)
GetLatestByCriteria returns the latest event per criterion plus the max observed position. The per-criterion lookups run inside one SQL statement (get_latest_by_criteria_v1 builds a UNION ALL of LIMIT-1 subqueries), so the whole context comes from one snapshot — assembling it from independent queries would let an event commit in between with a position below the observed maximum, invisible to a scalar expected-position check.
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, expectedPosition *eventstore.Position, streamConsistencyCondition *eventstore.Query) (transactionID string, globalID int64, err error)