mysql

package
v0.8.0-beta.27 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DateTimeFormat = "2006-01-02 15:04:05.999999"

Variables

View Source
var EmptyResultData = ResultData{}

Functions

func GetDBConnection

func GetDBConnection(dsn string) (*sql.DB, error)

GetDBConnection returns a DB Connection based on dsn.

func NewCommands

func NewCommands() engines.ClusterCommands

func NewManager

func NewManager(properties engines.Properties) (engines.DBManager, error)

func QueryRowsMap

func QueryRowsMap(db *sql.DB, query string, onRow func(RowMap) error, args ...interface{}) (err error)

QueryRowsMap is a convenience function allowing querying a result set while providing a callback function activated per read row.

func ScanRowsToArrays

func ScanRowsToArrays(rows *sql.Rows, onRow func([]CellData) error) error

ScanRowsToArrays is a convenience function, typically not called directly, which maps rows already read from the database into arrays of NullString

func ScanRowsToMaps

func ScanRowsToMaps(rows *sql.Rows, onRow func(RowMap) error) error

ScanRowsToMaps is a convenience function, typically not called directly, which maps rows already read from the database into RowMap entries.

Types

type CellData

type CellData sql.NullString

CellData is the result of a single (atomic) column in a single row

func RowToArray

func RowToArray(rows *sql.Rows, columns []string) []CellData

func (*CellData) MarshalJSON

func (cd *CellData) MarshalJSON() ([]byte, error)

func (*CellData) NullString

func (cd *CellData) NullString() *sql.NullString

func (*CellData) UnmarshalJSON

func (cd *CellData) UnmarshalJSON(b []byte) error

UnmarshalJSON reds this object from JSON

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 {
	Username string
	// contains filtered or unexported fields
}

func GetConfig

func GetConfig() *Config

func NewConfig

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

func (*Config) GetDBConnWithAddr

func (config *Config) GetDBConnWithAddr(addr string) (*sql.DB, error)

func (*Config) GetDBPort

func (config *Config) GetDBPort() int

func (*Config) GetLocalDBConn

func (config *Config) GetLocalDBConn() (*sql.DB, error)

type GTIDItem

type GTIDItem struct {
	ServerUUID string
	Ranges     string
}

GTIDItem represents an item in a set of GTID ranges, for example, the item: "ee194423-3040-11ee-9393-eab5dfc9b22a:1-5:8-10"

func NewGTIDItem

func NewGTIDItem(gtidString string) (*GTIDItem, error)

func (*GTIDItem) Explode

func (gtid *GTIDItem) Explode() (result []*GTIDItem)

func (*GTIDItem) String

func (gtid *GTIDItem) String() string

type GTIDSet

type GTIDSet struct {
	Items []*GTIDItem
}

func NewOracleGtidSet

func NewOracleGtidSet(gtidSet string) (res *GTIDSet, err error)

func (*GTIDSet) Explode

func (gtidSet *GTIDSet) Explode() (result []*GTIDItem)

func (*GTIDSet) IsEmpty

func (gtidSet *GTIDSet) IsEmpty() bool

func (*GTIDSet) RemoveUUID

func (gtidSet *GTIDSet) RemoveUUID(uuid string) (removed bool)

func (*GTIDSet) RetainUUID

func (gtidSet *GTIDSet) RetainUUID(uuid string) (anythingRemoved bool)

func (*GTIDSet) RetainUUIDs

func (gtidSet *GTIDSet) RetainUUIDs(uuids []string) (anythingRemoved bool)

func (*GTIDSet) SharedUUIDs

func (gtidSet *GTIDSet) SharedUUIDs(other *GTIDSet) (shared []string)

func (*GTIDSet) String

func (gtidSet *GTIDSet) String() string

type Manager

type Manager struct {
	engines.DBManagerBase
	DB *sql.DB
	// contains filtered or unexported fields
}

func (*Manager) CreateRoot

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

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) Demote

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

func (*Manager) DescribeUser

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

func (*Manager) EnableSemiSyncIfNeed

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

func (*Manager) EnsureServerID

func (mgr *Manager) EnsureServerID(ctx context.Context) (bool, error)

func (*Manager) Exec

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

func (*Manager) Follow

func (mgr *Manager) Follow(ctx context.Context, cluster *dcs.Cluster) error

func (*Manager) GetDBState

func (mgr *Manager) GetDBState(ctx context.Context, cluster *dcs.Cluster) *dcs.DBState

func (*Manager) GetGlobalState

func (mgr *Manager) GetGlobalState(ctx context.Context, db *sql.DB) (map[string]string, error)

func (*Manager) GetHealthiestMember

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

func (*Manager) GetMasterStatus

func (mgr *Manager) GetMasterStatus(context.Context, *sql.DB) (RowMap, error)

func (*Manager) GetMemberAddrs

func (mgr *Manager) GetMemberAddrs(_ context.Context, cluster *dcs.Cluster) []string

func (*Manager) GetMemberConnection

func (mgr *Manager) GetMemberConnection(cluster *dcs.Cluster, member *dcs.Member) (db *sql.DB, err error)

func (*Manager) GetOpTimestamp

func (mgr *Manager) GetOpTimestamp(ctx context.Context, db *sql.DB) (int64, error)

func (*Manager) GetReplicaRole

func (mgr *Manager) GetReplicaRole(ctx context.Context, cluster *dcs.Cluster) (string, error)

func (*Manager) GetSlaveStatus

func (mgr *Manager) GetSlaveStatus(context.Context, *sql.DB) (RowMap, error)

func (*Manager) GrantUserRole

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

func (*Manager) HasOtherHealthyMembers

func (mgr *Manager) HasOtherHealthyMembers(ctx context.Context, cluster *dcs.Cluster, leader string) []*dcs.Member

HasOtherHealthyMembers checks if there are any healthy members, excluding the leader

func (*Manager) InitializeCluster

func (mgr *Manager) InitializeCluster(context.Context, *dcs.Cluster) error

func (*Manager) InitiateCluster

func (mgr *Manager) InitiateCluster(*dcs.Cluster) error

func (*Manager) IsClusterInitialized

func (mgr *Manager) IsClusterInitialized(ctx context.Context, _ *dcs.Cluster) (bool, error)

IsClusterInitialized is a method to check if cluster is initialized or not

func (*Manager) IsCurrentMemberHealthy

func (mgr *Manager) IsCurrentMemberHealthy(ctx context.Context, cluster *dcs.Cluster) bool

func (*Manager) IsCurrentMemberInCluster

func (mgr *Manager) IsCurrentMemberInCluster(context.Context, *dcs.Cluster) bool

func (*Manager) IsDBStartupReady

func (mgr *Manager) IsDBStartupReady() bool

func (*Manager) IsLeader

func (mgr *Manager) IsLeader(ctx context.Context, _ *dcs.Cluster) (bool, error)

func (*Manager) IsLeaderMember

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

func (*Manager) IsMemberHealthy

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

func (*Manager) IsMemberLagging

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

func (*Manager) IsReadonly

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

func (*Manager) IsRootCreated

func (mgr *Manager) IsRootCreated(context.Context) (bool, error)

func (*Manager) IsRunning

func (mgr *Manager) IsRunning() bool

func (*Manager) JoinCurrentMemberToCluster

func (mgr *Manager) JoinCurrentMemberToCluster(context.Context, *dcs.Cluster) error

func (*Manager) LeaveMemberFromCluster

func (mgr *Manager) LeaveMemberFromCluster(context.Context, *dcs.Cluster, string) error

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(context.Context, string) error

func (*Manager) Promote

func (mgr *Manager) Promote(ctx context.Context, cluster *dcs.Cluster) error

func (*Manager) Query

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

func (*Manager) ReadCheck

func (mgr *Manager) ReadCheck(ctx context.Context, db *sql.DB) 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) ShutDownWithWait

func (mgr *Manager) ShutDownWithWait()

func (*Manager) Unlock

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

func (*Manager) WriteCheck

func (mgr *Manager) WriteCheck(ctx context.Context, db *sql.DB) bool

type NamedResultData

type NamedResultData struct {
	Columns []string
	Data    ResultData
}

type ResultData

type ResultData []RowData

ResultData is an ordered row set of RowData

type RowData

type RowData []CellData

RowData is the result of a single row, in positioned array format

func (*RowData) Args

func (rd *RowData) Args() []interface{}

func (*RowData) MarshalJSON

func (rd *RowData) MarshalJSON() ([]byte, error)

MarshalJSON will marshal this map as JSON

type RowMap

type RowMap map[string]CellData

RowMap represents one row in a result set. Its objective is to allow for easy, typed getters by column name.

func (*RowMap) GetBool

func (rm *RowMap) GetBool(key string) bool

func (*RowMap) GetInt

func (rm *RowMap) GetInt(key string) int

func (*RowMap) GetInt64

func (rm *RowMap) GetInt64(key string) int64

func (*RowMap) GetIntD

func (rm *RowMap) GetIntD(key string, def int) int

func (*RowMap) GetNullInt64

func (rm *RowMap) GetNullInt64(key string) sql.NullInt64

func (*RowMap) GetString

func (rm *RowMap) GetString(key string) string

func (*RowMap) GetStringD

func (rm *RowMap) GetStringD(key string, def string) string

GetStringD returns a string from the map, or a default value if the key does not exist

func (*RowMap) GetTime

func (rm *RowMap) GetTime(key string) time.Time

func (*RowMap) GetUint

func (rm *RowMap) GetUint(key string) uint

func (*RowMap) GetUint64

func (rm *RowMap) GetUint64(key string) uint64

func (*RowMap) GetUint64D

func (rm *RowMap) GetUint64D(key string, def uint64) uint64

func (*RowMap) GetUintD

func (rm *RowMap) GetUintD(key string, def uint) uint

Jump to

Keyboard shortcuts

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