postgres

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ActiveRecordTxnID represents the maximum XID8 value used for active records
	// to avoid XID wraparound issues (instead of using 0)
	ActiveRecordTxnID = uint64(9223372036854775807)
	MaxXID8Value      = "'9223372036854775807'::xid8"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MockPQDatabase added in v0.3.8

type MockPQDatabase struct {
	mock.Mock
}

MockPQDatabase simulates the behavior of a real PQDatabase.

func (*MockPQDatabase) Close added in v0.3.8

func (m *MockPQDatabase) Close() error

func (*MockPQDatabase) GetEngineType added in v0.3.8

func (m *MockPQDatabase) GetEngineType() string

func (*MockPQDatabase) IsReady added in v0.3.8

func (m *MockPQDatabase) IsReady(ctx context.Context) (bool, error)

type Option

type Option func(*Postgres)

Option - Option type

func MaxConnectionIdleTime added in v0.2.3

func MaxConnectionIdleTime(d time.Duration) Option

MaxConnectionIdleTime - Defines maximum connection idle for postgresql db

func MaxConnectionLifeTime added in v0.2.3

func MaxConnectionLifeTime(d time.Duration) Option

MaxConnectionLifeTime - Defines maximum connection lifetime for postgresql db

func MaxDataPerWrite added in v0.7.9

func MaxDataPerWrite(v int) Option

func MaxIdleConnections added in v0.2.3

func MaxIdleConnections(c int) Option

MaxIdleConnections - Defines maximum idle connections for postgresql db

func MaxOpenConnections added in v0.2.0

func MaxOpenConnections(size int) Option

MaxOpenConnections - Defines maximum open connections for postgresql db

func MaxRetries added in v0.7.9

func MaxRetries(v int) Option

func WatchBufferSize added in v0.7.9

func WatchBufferSize(v int) Option

type Postgres

type Postgres struct {
	ReadPool  *pgxpool.Pool
	WritePool *pgxpool.Pool

	Builder squirrel.StatementBuilderType
	// contains filtered or unexported fields
}

Postgres - Structure for Postresql instance

func New

func New(uri string, opts ...Option) (*Postgres, error)

New -

func NewWithSeparateURIs added in v0.8.5

func NewWithSeparateURIs(writerUri, readerUri string, opts ...Option) (*Postgres, error)

NewWithSeparateURIs -

func (*Postgres) Close

func (p *Postgres) Close() error

Close - Close postgresql instance

func (*Postgres) GetEngineType

func (p *Postgres) GetEngineType() string

GetEngineType - Get the engine type which is postgresql in string

func (*Postgres) GetMaxDataPerWrite added in v0.7.9

func (p *Postgres) GetMaxDataPerWrite() int

func (*Postgres) GetMaxRetries added in v0.7.9

func (p *Postgres) GetMaxRetries() int

func (*Postgres) GetWatchBufferSize added in v0.7.9

func (p *Postgres) GetWatchBufferSize() int

func (*Postgres) IsReady

func (p *Postgres) IsReady(ctx context.Context) (bool, error)

IsReady - Check if database is ready

func (*Postgres) Repair added in v1.4.6

func (p *Postgres) Repair(ctx context.Context, config *RepairConfig) (*RepairResult, error)

Repair performs XID counter repair to prevent XID wraparound issues This function uses a safe approach: only advance XID counter, don't modify existing data

type RepairConfig added in v1.4.6

type RepairConfig struct {
	BatchSize  int  // batch size for XID advancement
	MaxRetries int  // maximum number of retries
	RetryDelay int  // milliseconds
	DryRun     bool // perform a dry run without making changes
	Verbose    bool // enable verbose logging
}

RepairConfig holds configuration for the XID counter repair operation

func DefaultRepairConfig added in v1.4.6

func DefaultRepairConfig() *RepairConfig

DefaultRepairConfig returns default configuration for XID counter repair

type RepairResult added in v1.4.6

type RepairResult struct {
	CreatedTxIdFixed int // Number of XIDs advanced in counter
	Errors           []error
	Duration         string
}

RepairResult holds the results of the XID counter repair operation

type XID8 added in v1.4.6

type XID8 pguint64

XID8 represents a PostgreSQL xid8 (64-bit transaction ID) type

func (*XID8) AssignTo added in v1.4.6

func (x *XID8) AssignTo(dst interface{}) error

AssignTo assigns the value to the destination

func (*XID8) DecodeBinary added in v1.4.6

func (x *XID8) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error

DecodeBinary decodes binary format

func (*XID8) DecodeText added in v1.4.6

func (x *XID8) DecodeText(ci *pgtype.ConnInfo, src []byte) error

DecodeText decodes text format

func (XID8) EncodeBinary added in v1.4.6

func (x XID8) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

EncodeBinary encodes to binary format

func (XID8) EncodeText added in v1.4.6

func (x XID8) EncodeText(ci *pgtype.ConnInfo, buf []byte) ([]byte, error)

EncodeText encodes to text format

func (XID8) Get added in v1.4.6

func (x XID8) Get() interface{}

Get returns the underlying value

func (*XID8) Scan added in v1.4.6

func (x *XID8) Scan(src interface{}) error

Scan implements the database/sql Scanner interface

func (*XID8) Set added in v1.4.6

func (x *XID8) Set(src interface{}) error

Set sets the XID8 value from various input types

func (XID8) Value added in v1.4.6

func (x XID8) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface

Jump to

Keyboard shortcuts

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