confpostgres

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext added in v0.1.2

func FromContext(ctx context.Context) sqlx.DBExecutor

func SlaveFromContext added in v0.1.2

func SlaveFromContext(ctx context.Context) sqlx.DBExecutor

func SwitchSlave added in v0.1.2

func SwitchSlave(executor sqlx.DBExecutor) sqlx.DBExecutor

func WithDB added in v0.1.2

func WithDB(db sqlx.DBExecutor) func(ctx context.Context) context.Context

Types

type CanSlave added in v0.1.2

type CanSlave interface {
	UseSlave() sqlx.DBExecutor
}

type Postgres

type Postgres struct {
	Ctx             context.Context
	DBName          string           `env:""`
	Host            string           `env:",upstream"`
	SlaveHost       string           `env:",upstream"`
	Port            int              `env:""`
	User            string           `env:""`
	Password        envconf.Password `env:""`
	Extra           string
	Extensions      []string
	PoolSize        int
	ConnMaxLifetime envconf.Duration
	Database        *sqlx.Database `env:"-"`
	*sqlx.DB        `env:"-"`
	// contains filtered or unexported fields
}

func (*Postgres) Commands

func (m *Postgres) Commands() []*cobra.Command

func (*Postgres) Get

func (m *Postgres) Get() *sqlx.DB

func (*Postgres) Init

func (m *Postgres) Init()

func (*Postgres) LivenessCheck added in v0.1.2

func (m *Postgres) LivenessCheck() map[string]string

func (*Postgres) SetDefaults

func (m *Postgres) SetDefaults()

func (*Postgres) UseSlave added in v0.1.2

func (m *Postgres) UseSlave() sqlx.DBExecutor

type PostgresEndpoint added in v0.1.2

type PostgresEndpoint struct {
	Endpoint      envconf.Endpoint `env:""`
	SlaveEndpoint envconf.Endpoint `env:""`
	DBName        string           `env:",opt"`
	Database      *sqlx.Database   `env:"-"`

	Extensions      []string
	PoolSize        int
	ConnMaxLifetime envconf.Duration

	*sqlx.DB `env:"-"`
	// contains filtered or unexported fields
}

func (*PostgresEndpoint) Init added in v0.1.2

func (m *PostgresEndpoint) Init()

func (*PostgresEndpoint) LivenessCheck added in v0.1.2

func (m *PostgresEndpoint) LivenessCheck() map[string]string

func (*PostgresEndpoint) SetDefaults added in v0.1.2

func (m *PostgresEndpoint) SetDefaults()

func (*PostgresEndpoint) UseSlave added in v0.1.2

func (m *PostgresEndpoint) UseSlave() sqlx.DBExecutor

type Retry

type Retry struct {
	Repeats  int
	Interval envconf.Duration
}

func (Retry) Do

func (r Retry) Do(exec func() error) (err error)

func (*Retry) SetDefaults added in v0.1.2

func (r *Retry) SetDefaults()

Jump to

Keyboard shortcuts

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