Documentation ¶
Index ¶
- Variables
- func CatchSignals(c chan os.Signal, s os.Signal)
- func ConnectToMemSQL(config Config) error
- func ConstantRefresh(sleepTime time.Duration) func(int) time.Duration
- func DBAttachLeaf(host string, port int) error
- func DBDetachLeaf(host string, port int) error
- func DBGetUserDatabases() ([]string, error)
- func DBGetVariable(varName string) (string, error)
- func DBRebalancePartitions(database string) error
- func DBRestoreRedundancy(database string) error
- func DBRowCount(database, table string) (string, error)
- func DBSetVariable(db string) error
- func DBSnapshotDatabase(db string) error
- func ExponentialBackoffRefresh(tries int) time.Duration
- func GetNodeIDs(nodeType string) ([]string, error)
- func GetUserConfirmation(message, instruction, confirmString string)
- func LineWrapper(s string, maxLength int) string
- func MasterSlaveCheck(partitions []*ClusterStatus) error
- func OpsMemsqlGetVersion(memsqlID string) (string, error)
- func OpsMemsqlUpdateConfig(memsqlID, key, value string, option ...string) error
- func OpsMemsqlUpgrade(memsqlID string, arguments ...string) error
- func OpsNodeManagement(command, memsqlID string, arguments ...string) error
- func OpsVersionCheck() ([]string, error)
- func OpsWaitMemsqlsOnlineConnected(numNodes int) error
- func OrphanCheck(partitions []*ClusterStatus) error
- func SetupLogging(config Config) (func(), error)
- func TestGetDB(t *testing.T) *sqlx.DB
- type AgentInfo
- type ClusterStatus
- type Config
- type Leaf
- type MemsqlInfo
- type RestoreRedundancy
- type StateChange
- type StateNextRefreshFunc
- type StateRefreshFunc
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoMaster = errors.New("util/ops: Master Aggregator not found")
)
Set Custom error messages
Functions ¶
func CatchSignals ¶
CatchSignals will setup Notify to relay specific OS signals to a specified channel and handle the signals that are on the channel
func DBAttachLeaf ¶
DBAttachLeaf will attach a specified host (ATTACH LEAF 'host':port)
func DBDetachLeaf ¶
DBDetachLeaf will detach a specified host (DETACH LEAF 'host':port)
func DBGetUserDatabases ¶
DBGetUserDatabases returns all user databases
func DBGetVariable ¶
DBGetVariable returns value of variable name specified
func DBRebalancePartitions ¶
DBRebalancePartitions will run rebalance on specified DB
func DBRestoreRedundancy ¶
DBRestoreRedundancy will restore redundancy on specified DB
func DBRowCount ¶
DBRowCount returns a count for specified table
func DBSnapshotDatabase ¶
DBSnapshotDatabase executes a snapshot of provided databse
func GetNodeIDs ¶
GetNodeIDs returns a slice of MemSQL node IDs by type (e.g. MASTER)
func GetUserConfirmation ¶
func GetUserConfirmation(message, instruction, confirmString string)
GetUserConfirmation waits for user to confirm
func LineWrapper ¶
LineWrapper returns a string with line breaks at the specified line length
func MasterSlaveCheck ¶
func MasterSlaveCheck(partitions []*ClusterStatus) error
MasterSlaveCheck will check each partition has a Master and Slave masterSlaveCheck Requires a slice if partitions from Cluster Status util.ClusterStatus will return a slice of pointers to the struct
func OpsMemsqlGetVersion ¶
OpsMemsqlGetVersion returns MemSQL Version for provided memsql_id
func OpsMemsqlUpdateConfig ¶
OpsMemsqlUpdateConfig updates memsql.cnf Accepts memsqlID, key, value, and a list of options We return output of the command and nill if not err
func OpsMemsqlUpgrade ¶
OpsMemsqlUpgrade upgrades a specified memsql node
func OpsNodeManagement ¶
OpsNodeManagement executes memsql-ops commands which take a single memsql_id as a positional argument. (start, stop ...)
func OpsVersionCheck ¶
OpsVersionCheck return Memsql Ops Version memsql-ops version --client-version-only
func OpsWaitMemsqlsOnlineConnected ¶
OpsWaitMemsqlsOnlineConnected checks and waits for the state of a specified number of nodes to be online and connected
func OrphanCheck ¶
func OrphanCheck(partitions []*ClusterStatus) error
OrphanCheck will check for any orphan partitions orphanCheck requires a slice if partitions from Cluster Status util.ClusterStatus will return a slice of pointers to the struct
func SetupLogging ¶
Types ¶
type AgentInfo ¶
type AgentInfo struct { AgentID string `json:"agent_id"` Host string `json:"host"` Port int `json:"port"` Role string `json:"role"` State string `json:"state"` Version string `json:"version"` }
AgentInfo struct for memsql-ops agent-list
func OpsAgentList ¶
OpsAgentList returns a slice of agent-list
type ClusterStatus ¶
type ClusterStatus struct { Host string `db:"Host"` Port int `db:"Port"` Database string `db:"Database"` Role string `db:"Role"` State string `db:"State"` Position []uint8 `db:"Position"` Details string `db:"Details"` }
ClusterStatus - struct for data returned from query
func DBShowClusterStatus ¶
func DBShowClusterStatus() ([]*ClusterStatus, error)
DBShowClusterStatus returns output of show cluster status Return a slice of pointers to the ClusterStatus struct
type Config ¶
type Config struct { MasterHost string MasterPort int MasterUser string MasterPass string LogPath string VersionHash string SkipVersionCheck bool OutputWidth int }
Config struct for commandline flags
type Leaf ¶
type Leaf struct { Host string `db:"Host"` Port int `db:"Port"` PairHost string `db:"Pair_Host"` PairPort int `db:"Pair_Port"` AG int `db:"Availability_Group"` OpenConn int `db:"Opened_Connections"` AvgRT []uint8 `db:"Average_Roundtrip_Latency_ms"` State string `db:"State"` }
Leaf - struct for leaf data return from query
func DBShowLeaves ¶
DBShowLeaves returns the output of show leaves Return a slice of pointers to the Leaf struct
type MemsqlInfo ¶
type MemsqlInfo struct { MemsqlID string `json:"memsql_id"` AgentID string `json:"agent_id"` MemsqlVersion string `json:"memsql_version"` Role string `json:"role"` Host string `json:"host"` Port int `json:"port"` Group int `json:"availability_group"` ClusterState string `json:"cluster_state"` RunState string `json:"run_state"` State string `json:"state"` }
MemsqlInfo struct for memsql-ops memsql-list
func OpsMemsqlList ¶
func OpsMemsqlList(args ...string) ([]MemsqlInfo, error)
OpsMemsqlList return a slice of memsql-list By default we expect json. Do not pass in `-q`
type RestoreRedundancy ¶
type RestoreRedundancy struct { Action string `db:"Action"` Ordinal int `db:"Ordinal"` TargetHost string `db:"Target_Host"` TargetPort int `db:"Target_Port"` Phase int `db:"Phase"` }
RestoreRedundancy data return from Exlpain Restore Redundancy
func DBExplainRestoreRedundancy ¶
func DBExplainRestoreRedundancy(database string) ([]*RestoreRedundancy, error)
DBExplainRestoreRedundancy will run explain restore redundancy on specified DB
type StateChange ¶
type StateChange struct { Target interface{} Timeout time.Duration NextRefresh StateNextRefreshFunc Refresh StateRefreshFunc }
func (StateChange) WaitForState ¶
func (conf StateChange) WaitForState() error
type StateNextRefreshFunc ¶
type StateRefreshFunc ¶
type StateRefreshFunc func() (state interface{}, err error)