postgres

package
v0.7.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: AGPL-3.0 Imports: 21 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")
)

Functions

func ParsePgLsn

func ParsePgLsn(str string) int64

func ParsePrimaryConnInfo

func ParsePrimaryConnInfo(str string) map[string]string

func ParseQuery

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

Types

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 History

type History struct {
	ParentTimeline int64
	SwitchPoint    int64
}

type Manager

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

func NewManager

func NewManager(logger logger.Logger) (*Manager, 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) 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) 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) 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 {
	component.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