Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - func ExecCommand(name string, args ...string) (string, error)
 - func FormatPgLsn(lsn int64) string
 - func NewCommands() engines.ClusterCommands
 - func NewFakeCommander(f func() error, stdout, stderr *bytes.Buffer) func(name string, args ...string) LocalCommand
 - func NewManager(properties map[string]string) (engines.DBManager, error)
 - func ParsePgLsn(str string) int64
 - func ParsePgWalDumpError(errorInfo string, lsnStr string) string
 - func ParsePrimaryConnInfo(str string) map[string]string
 - func ParseQuery(str string) (result []map[string]interface{}, err error)
 - func PgCtl(arg string) (string, error)
 - func PgRewind(args ...string) (string, error)
 - func PgWalDump(args ...string) (string, error)
 - func Psql(args ...string) (string, error)
 - type Commands
 - type Config
 - type ConsensusMemberHealthStatus
 - type FakeCommand
 - type History
 - type HistoryFile
 - type LocalCommand
 - type Manager
 - func (mgr *Manager) CreateUser(ctx context.Context, userName, password, _ string) error
 - func (mgr *Manager) DeleteUser(ctx context.Context, userName string) error
 - func (mgr *Manager) DescribeUser(ctx context.Context, userName string) (*models.UserInfo, error)
 - func (mgr *Manager) Exec(ctx context.Context, sql string) (result int64, err error)
 - func (mgr *Manager) ExecLeader(ctx context.Context, sql string, cluster *dcs.Cluster) (int64, error)
 - func (mgr *Manager) ExecOthers(ctx context.Context, sql string, host string) (resp pgconn.CommandTag, err error)
 - func (mgr *Manager) ExecWithHost(ctx context.Context, sql string, host string) (result int64, err error)
 - func (mgr *Manager) GetHealthiestMember(*dcs.Cluster, string) *dcs.Member
 - func (mgr *Manager) GetIsLeader() (bool, bool)
 - func (mgr *Manager) GetLeaderAddr(ctx context.Context) (string, error)
 - func (mgr *Manager) GetPgCurrentSetting(ctx context.Context, setting string) (string, error)
 - func (mgr *Manager) GrantUserRole(ctx context.Context, userName, roleName string) error
 - func (mgr *Manager) IsLeaderMember(ctx context.Context, cluster *dcs.Cluster, member *dcs.Member) (bool, error)
 - func (mgr *Manager) IsPgReady(ctx context.Context) bool
 - func (mgr *Manager) IsRunning() bool
 - func (mgr *Manager) ListSystemAccounts(ctx context.Context) ([]models.UserInfo, error)
 - func (mgr *Manager) ListUsers(ctx context.Context) ([]models.UserInfo, error)
 - func (mgr *Manager) Lock(ctx context.Context, reason string) error
 - func (mgr *Manager) PgReload(ctx context.Context) error
 - func (mgr *Manager) Query(ctx context.Context, sql string) (result []byte, err error)
 - func (mgr *Manager) QueryLeader(ctx context.Context, sql string, cluster *dcs.Cluster) (result []byte, err error)
 - func (mgr *Manager) QueryOthers(ctx context.Context, sql string, host string) (rows pgx.Rows, err error)
 - func (mgr *Manager) QueryWithHost(ctx context.Context, sql string, host string) (result []byte, err error)
 - func (mgr *Manager) ReadCheck(ctx context.Context, host string) bool
 - func (mgr *Manager) Recover(context.Context, *dcs.Cluster) error
 - func (mgr *Manager) RevokeUserRole(ctx context.Context, userName, roleName string) error
 - func (mgr *Manager) SetIsLeader(isLeader bool)
 - func (mgr *Manager) ShutDownWithWait()
 - func (mgr *Manager) Unlock(ctx context.Context) error
 - func (mgr *Manager) UnsetIsLeader()
 - func (mgr *Manager) WriteCheck(ctx context.Context, host string) bool
 
- type PGStandby
 - type PgBaseIFace
 - type PgIFace
 - type PgxIFace
 - type PgxPoolIFace
 - type PidFile
 
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 FormatPgLsn ¶
func NewCommands ¶
func NewCommands() engines.ClusterCommands
func NewFakeCommander ¶
func ParsePgLsn ¶
func ParsePgWalDumpError ¶
func ParsePrimaryConnInfo ¶
func ParseQuery ¶
Types ¶
type Commands ¶
type Commands struct {
	// contains filtered or unexported fields
}
    func (*Commands) ConnectCommand ¶
func (*Commands) ConnectExample ¶
func (m *Commands) ConnectExample(info *engines.ConnectionInfo, client string) string
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 (*Config) GetConnectURLWithHost ¶
func (*Config) GetConsensusIPPort ¶
type FakeCommand ¶
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 HistoryFile ¶
type HistoryFile struct {
	History []History
}
    func ParseHistory ¶
func ParseHistory(str string) *HistoryFile
type LocalCommand ¶
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 (*Manager) DeleteUser ¶
func (*Manager) DescribeUser ¶
func (*Manager) ExecLeader ¶
func (*Manager) ExecOthers ¶
func (*Manager) ExecWithHost ¶
func (*Manager) GetHealthiestMember ¶
func (*Manager) GetIsLeader ¶
GetIsLeader returns whether the "isLeader" is set or not and whether current member is leader or not
func (*Manager) GetLeaderAddr ¶
GetLeaderAddr query leader addr from db kernel
func (*Manager) GetPgCurrentSetting ¶
func (*Manager) GrantUserRole ¶
func (*Manager) IsLeaderMember ¶
func (*Manager) ListSystemAccounts ¶
func (*Manager) QueryLeader ¶
func (*Manager) QueryOthers ¶
func (*Manager) QueryWithHost ¶
func (*Manager) RevokeUserRole ¶
func (*Manager) SetIsLeader ¶
func (*Manager) ShutDownWithWait ¶
func (mgr *Manager) ShutDownWithWait()
func (*Manager) UnsetIsLeader ¶
func (mgr *Manager) UnsetIsLeader()
type PGStandby ¶
func ParsePGSyncStandby ¶
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
}
    
      
      Source Files
      ¶
    
   Click to show internal directories. 
   Click to hide internal directories.