sinkprod

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sinkprod contains configuration and providers for connecting to production database(s).

Index

Constants

This section is empty.

Variables

View Source
var (
	StagingSchemaDefault = ident.MustSchema(ident.New("_replicator"), ident.Public)
	StagingSchemaLegacy  = ident.MustSchema(ident.New("_cdc_sink"), ident.Public)
)

These are default names for the staging database schema.

Set is used by Wire.

Functions

func ProvideStagingDB

func ProvideStagingDB(
	ctx context.Context, config *StagingConfig, pool *types.StagingPool,
) (ident.StagingSchema, error)

ProvideStagingDB is called by Wire to retrieve the name of the staging SQL DATABASE. If StagingSchemaDefault does not exist, but StagingSchemaLegacy does, then the latter will be returned.

func ProvideStagingPool

func ProvideStagingPool(
	ctx *stopper.Context, config *StagingConfig, diags *diag.Diagnostics, tgtConfig *TargetConfig,
) (*types.StagingPool, error)

ProvideStagingPool is called by Wire to create a connection pool that accesses the staging cluster. The pool will be closed when the context is stopped.

func ProvideStatementCache

func ProvideStatementCache(
	ctx *stopper.Context, config *TargetConfig, pool *types.TargetPool, diags *diag.Diagnostics,
) (*types.TargetStatements, error)

ProvideStatementCache is called by Wire to construct a prepared-statement cache. Anywhere the associated TargetPool is reused should also reuse the cache.

func ProvideTargetPool

func ProvideTargetPool(
	ctx *stopper.Context, config *TargetConfig, diags *diag.Diagnostics,
) (*types.TargetPool, error)

ProvideTargetPool is called by Wire to create a connection pool that accesses the target cluster. The pool will be closed when the context is stopped.

Types

type CommonConfig

type CommonConfig struct {
	// Connection string for the database.
	Conn string
	// The maximum lifetime of an idle connection.
	IdleTime time.Duration
	// The length of time to jitter disconnections over.
	JitterTime time.Duration
	// The maximum lifetime for a database connection; improves
	// loadbalancer compatibility.
	MaxLifetime time.Duration
	// The number of connections to the target database. If zero, a
	// default value will be used.
	MaxPoolSize int
}

CommonConfig defines settings that are shared by StagingConfig and TargetConfig.

type StagingConfig

type StagingConfig struct {
	CommonConfig
	// Create the destination schema.
	CreateSchema bool
	// The name of a SQL schema in the staging cluster to store
	// metadata in.
	Schema ident.Schema
}

StagingConfig defines staging-database connection behaviors.

func (*StagingConfig) Bind

func (c *StagingConfig) Bind(f *pflag.FlagSet)

Bind adds flags to the set.

func (*StagingConfig) Preflight

func (c *StagingConfig) Preflight() error

Preflight ensures that unset configuration options have sane defaults and returns an error if the StagingConfig is missing any fields for which a default cannot be provided.

type TargetConfig

type TargetConfig struct {
	CommonConfig

	// The maximum length of time to wait for an incoming transaction
	// to settle (i.e. to detect stalls in the target database).
	ApplyTimeout time.Duration
	// The number of prepared statements to retain in the target
	// database connection pool. Depending on the database in question,
	// there may be more or fewer available resources to retain
	// statements.
	StatementCacheSize int
}

TargetConfig defines target-database connection behaviors.

func (*TargetConfig) Bind

func (c *TargetConfig) Bind(f *pflag.FlagSet)

Bind adds flags to the set.

func (*TargetConfig) Preflight

func (c *TargetConfig) Preflight() error

Preflight ensures that unset configuration options have sane defaults and returns an error if the TargetConfig is missing any fields for which a default cannot be provided.

Jump to

Keyboard shortcuts

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