postgres

package
v0.8.0-beta.35 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectionURLKey = "url"
	DefaultPort      = 5432
)
View Source
const (
	PGDATA  = "PGDATA"
	PGMAJOR = "PG_MAJOR"
)
View Source
const (
	ReplicationMode = "replication_mode"
	SyncStandBys    = "sync_standbys"
	PrimaryConnInfo = "primary_conninfo"
	TimeLine        = "timeline"
)
View Source
const (
	Asynchronous = "asynchronous"
	Synchronous  = "synchronous"
)

Variables

View Source
var (
	ClusterHasNoLeader = errors.New("cluster has no leader now")
)
View Source
var LocalCommander = NewExecCommander

Functions

func ExecCommand

func ExecCommand(name string, args ...string) (string, error)

func FormatPgLsn

func FormatPgLsn(lsn int64) string

func NewCommands

func NewCommands() engines.ClusterCommands

func NewFakeCommander

func NewFakeCommander(f func() error, stdout, stderr *bytes.Buffer) func(name string, args ...string) LocalCommand

func NewManager

func NewManager(properties map[string]string) (engines.DBManager, error)

func ParsePgLsn

func ParsePgLsn(str string) int64

func ParsePgWalDumpError

func ParsePgWalDumpError(errorInfo string, lsnStr string) string

func ParsePrimaryConnInfo

func ParsePrimaryConnInfo(str string) map[string]string

func ParseQuery

func ParseQuery(str string) (result []map[string]interface{}, err error)

func PgCtl

func PgCtl(arg string) (string, error)

func PgRewind

func PgRewind(args ...string) (string, error)

func PgWalDump

func PgWalDump(args ...string) (string, error)

func Psql

func Psql(args ...string) (string, error)

Types

type Commands

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

func (*Commands) ConnectCommand

func (m *Commands) ConnectCommand(connectInfo *engines.AuthInfo) []string

func (*Commands) ConnectExample

func (m *Commands) ConnectExample(info *engines.ConnectionInfo, client string) string

func (*Commands) Container

func (m *Commands) Container() string

func (*Commands) ExecuteCommand

func (m *Commands) ExecuteCommand(scripts []string) ([]string, []corev1.EnvVar, error)

type Config

type Config struct {
	URL            string
	Username       string
	Password       string
	Host           string
	Port           int
	Database       string
	MaxConnections int32
	MinConnections int32
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(properties map[string]string) (*Config, error)

func (*Config) GetConnectURLWithHost

func (config *Config) GetConnectURLWithHost(host string) string

func (*Config) GetConsensusIPPort

func (config *Config) GetConsensusIPPort(cluster *dcs.Cluster, name string) string

func (*Config) GetDBPort

func (config *Config) GetDBPort() int

type ConsensusMemberHealthStatus

type ConsensusMemberHealthStatus struct {
	Connected   bool
	LogDelayNum int64
}

type FakeCommand

type FakeCommand struct {
	Stdout     *bytes.Buffer
	Stderr     *bytes.Buffer
	RunnerFunc func() error
}

func (*FakeCommand) GetStderr

func (cmd *FakeCommand) GetStderr() *bytes.Buffer

func (*FakeCommand) GetStdout

func (cmd *FakeCommand) GetStdout() *bytes.Buffer

func (*FakeCommand) Run

func (cmd *FakeCommand) Run() error

type History

type History struct {
	ParentTimeline int64
	SwitchPoint    int64
}

type HistoryFile

type HistoryFile struct {
	History []History
}

func ParseHistory

func ParseHistory(str string) *HistoryFile

type LocalCommand

type LocalCommand interface {
	Run() error
	GetStdout() *bytes.Buffer
	GetStderr() *bytes.Buffer
}

func NewExecCommander

func NewExecCommander(name string, args ...string) LocalCommand

type Manager

type Manager struct {
	engines.DBManagerBase
	MajorVersion int
	Pool         PgxPoolIFace
	Proc         *process.Process
	Config       *Config
	// contains filtered or unexported fields
}

func (*Manager) CreateUser

func (mgr *Manager) CreateUser(ctx context.Context, userName, password string) error

func (*Manager) DeleteUser

func (mgr *Manager) DeleteUser(ctx context.Context, userName string) error

func (*Manager) DescribeUser

func (mgr *Manager) DescribeUser(ctx context.Context, userName string) (*models.UserInfo, error)

func (*Manager) Exec

func (mgr *Manager) Exec(ctx context.Context, sql string) (result int64, err error)

Exec is equivalent to ExecWithHost(ctx, sql, ""), exec itself.

func (*Manager) ExecLeader

func (mgr *Manager) ExecLeader(ctx context.Context, sql string, cluster *dcs.Cluster) (result int64, err error)

func (*Manager) ExecOthers

func (mgr *Manager) ExecOthers(ctx context.Context, sql string, host string) (resp pgconn.CommandTag, err error)

func (*Manager) ExecWithHost

func (mgr *Manager) ExecWithHost(ctx context.Context, sql string, host string) (result int64, err error)

func (*Manager) GetHealthiestMember

func (mgr *Manager) GetHealthiestMember(*dcs.Cluster, string) *dcs.Member

func (*Manager) GetIsLeader

func (mgr *Manager) GetIsLeader() (bool, bool)

GetIsLeader returns whether the "isLeader" is set or not and whether current member is leader or not

func (*Manager) GetLeaderAddr

func (mgr *Manager) GetLeaderAddr(ctx context.Context) (string, error)

GetLeaderAddr query leader addr from db kernel

func (*Manager) GetPgCurrentSetting

func (mgr *Manager) GetPgCurrentSetting(ctx context.Context, setting string) (string, error)

func (*Manager) GrantUserRole

func (mgr *Manager) GrantUserRole(ctx context.Context, userName, roleName string) error

func (*Manager) IsLeaderMember

func (mgr *Manager) IsLeaderMember(ctx context.Context, cluster *dcs.Cluster, member *dcs.Member) (bool, error)

func (*Manager) IsPgReady

func (mgr *Manager) IsPgReady(ctx context.Context) bool

func (*Manager) IsRunning

func (mgr *Manager) IsRunning() bool

func (*Manager) ListSystemAccounts

func (mgr *Manager) ListSystemAccounts(ctx context.Context) ([]models.UserInfo, error)

func (*Manager) ListUsers

func (mgr *Manager) ListUsers(ctx context.Context) ([]models.UserInfo, error)

func (*Manager) Lock

func (mgr *Manager) Lock(ctx context.Context, reason string) error

func (*Manager) PgReload

func (mgr *Manager) PgReload(ctx context.Context) error

func (*Manager) Query

func (mgr *Manager) Query(ctx context.Context, sql string) (result []byte, err error)

Query is equivalent to QueryWithHost(ctx, sql, ""), query itself.

func (*Manager) QueryLeader

func (mgr *Manager) QueryLeader(ctx context.Context, sql string, cluster *dcs.Cluster) (result []byte, err error)

func (*Manager) QueryOthers

func (mgr *Manager) QueryOthers(ctx context.Context, sql string, host string) (rows pgx.Rows, err error)

func (*Manager) QueryWithHost

func (mgr *Manager) QueryWithHost(ctx context.Context, sql string, host string) (result []byte, err error)

func (*Manager) ReadCheck

func (mgr *Manager) ReadCheck(ctx context.Context, host string) bool

func (*Manager) Recover

func (mgr *Manager) Recover(context.Context) error

func (*Manager) RevokeUserRole

func (mgr *Manager) RevokeUserRole(ctx context.Context, userName, roleName string) error

func (*Manager) SetIsLeader

func (mgr *Manager) SetIsLeader(isLeader bool)

func (*Manager) ShutDownWithWait

func (mgr *Manager) ShutDownWithWait()

func (*Manager) Unlock

func (mgr *Manager) Unlock(ctx context.Context) error

func (*Manager) UnsetIsLeader

func (mgr *Manager) UnsetIsLeader()

func (*Manager) WriteCheck

func (mgr *Manager) WriteCheck(ctx context.Context, host string) bool

type PGStandby

type PGStandby struct {
	Types   string
	Amount  int
	Members mapset.Set[string]
	HasStar bool
}

func ParsePGSyncStandby

func ParsePGSyncStandby(standbyRow string) (*PGStandby, error)

type PgBaseIFace

type PgBaseIFace interface {
	GetMemberRoleWithHost(ctx context.Context, host string) (string, error)
	IsMemberHealthy(ctx context.Context, cluster *dcs.Cluster, member *dcs.Member) bool
	Query(ctx context.Context, sql string) (result []byte, err error)
	Exec(ctx context.Context, sql string) (result int64, err error)
}

type PgIFace

type PgIFace interface {
	engines.DBManager
	PgBaseIFace
}

type PgxIFace

type PgxIFace interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
	Ping(ctx context.Context) error
}

type PgxPoolIFace

type PgxPoolIFace interface {
	PgxIFace
	Acquire(ctx context.Context) (*pgxpool.Conn, error)
	Close()
}

PgxPoolIFace is interface representing pgx pool

type PidFile

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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