proxysql

package module
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2018 License: GPL-3.0 Imports: 8 Imported by: 0

README

Golang ProxySQL Library


1.introduce

A ProxySQL Go library.

2. Requirements

  1. Go 1.7 or higher.
  2. ProxySQL 1.3.x
3. Installation

Simple install the package to your $GOPATH with the go tool from shell:

# go get -u github.com/imSQL/proxysql

Make sure git command is installed on your OS.

4. Usage

example:

list all mysql_users .

conn, err := NewConn("172.18.10.111", 13306, "admin", "admin")
if err != nil {
	t.Error(conn, err)
}

conn.SetCharacter("utf8")
conn.SetCollation("utf8_general_ci")
conn.MakeDBI()

db, err := conn.OpenConn()
if err != nil {
	t.Error(db, err)
}

allusers, err := FindAllUserInfo(db, 1, 0)
if err != nil {
	t.Error(allusers, err)
}
5. Test

You can execute 'go test' command to test this project.

if proxysql is listening 172.18.10.136:13306, execute follow command:

# go test --args -addr 172.18.10.136 -port 13306 -user admin -pass admin
Donate

If you like the project and want to buy me a cola, you can through:

PayPal 微信

Documentation

Index

Constants

View Source
const (
	CmdProxyReadOnly               = `PROXYSQL READONLY`
	CmdProxyReadWrite              = `PROXYSQL READWRITE`
	CmdProxyStart                  = `PROXYSQL START`
	CmdProxyRestart                = `PROXYSQL RESTART`
	CmdProxyStop                   = `PROXYSQL STOP`
	CmdProxyPause                  = `PROXYSQL PAUSE`
	CmdProxyResume                 = `PROXYSQL RESUME`
	CmdProxyShutdown               = `PROXYSQL SHUTDOWN`
	CmdProxyFlushLogs              = `PROXYSQL FLUSH LOGS`
	CmdProxyKill                   = `PROXYSQL KILL`
	CmdLoadUserToRuntime           = `LOAD MYSQL USERS TO RUNTIME`
	CmdSaveUserToDisk              = `SAVE MYSQL USERS TO DISK`
	CmdLoadServerToRuntime         = `LOAD MYSQL SERVERS TO RUNTIME`
	CmdSaveServerToDisk            = `SAVE MYSQL SERVERS TO DISK`
	CmdLoadQueryRulesToRuntime     = `LOAD MYSQL QUERY RULES TO RUNTIME`
	CmdSaveQueryRulesToDisk        = `SAVE MYSQL QUERY RULES TO DISK`
	CmdLoadSchedulerToRuntime      = `LOAD SCHEDULER TO RUNTIME`
	CmdSaveSchedulerToDisk         = `SAVE SCHEDULER TO DISK`
	CmdLoadMySQLVariablesToRuntime = `LOAD MYSQL VARIABLES TO RUNTIME`
	CmdSaveMySQLVariablesToDisk    = `SAVE MYSQL VARIABLES TO DISK`
	CmdLoadAdminVariablesToRuntime = `LOAD ADMIN VARIABLES TO RUNTIME`
	CmdSaveAdminVariablesToDisk    = `SAVE ADMIN VARIABLES TO DISK`
)

define commands

View Source
const (
	/*new query rules*/
	StmtAddOneQr = `
	INSERT 
	INTO 
		mysql_query_rules(rule_id,username) 
	VALUES(%d,%s)`

	/*delete a query rules*/
	StmtDeleteOneQr = `
	DELETE 
	FROM 
		mysql_query_rules 
	WHERE rule_id = %d`

	/*query all query rules.*/
	StmtFindAllQr = `` /* 1040-byte string literal not displayed */

	/*find last insert rule_id*/
	StmtFindLastRuleId = `
	SELECT 
		max(rule_id)
	FROM mysql_query_rules
	WHERE 
		username = %s`

	/*update a query rules.*/
	StmtUpdateOneQr = `` /* 477-byte string literal not displayed */

)
View Source
const (
	// add a new replication hostgroup
	StmtAddOneRHG = `
	INSERT INTO 
		mysql_replication_hostgroups(writer_hostgroup,reader_hostgroup,comment)
	VALUES(%d,%d,%q)`

	// Update a replication hostgroup.
	StmtUpdateOneRHG = `
	UPDATE 
		mysql_replication_hostgroups
	SET 
		writer_hostgroup = %d,
		reader_hostgroup = %d,
		comment = %q
	`

	// Delete a replication hostgroup.
	StmtDeleteOneRHG = `
	DELETE FROM 
		mysql_replication_hostgroups
	WHERE
		writer_hostgroup = %d
	AND
		reader_hostgroup = %d
	`

	StmtQueryAllRHGs = `
	SELECT 
		* 
	FROM
		mysql_replication_hostgroups
	LIMIT %d 
	OFFSET %d
	`
)
View Source
const (
	/*add a new scheduler*/
	StmtAddOneScheduler = `
	INSERT 
	INTO 
		scheduler(id,filename,interval_ms,active,arg1,arg2,arg3,arg4,arg5) 
	VALUES(%d,%q,%d,%d,%q,%q,%q,%q,%q)`

	/*delete a scheduler*/
	StmtDeleteOneScheduler = `
	DELETE 
	FROM 
		scheduler 
	WHERE id = %d`

	/*update a scheduler*/
	StmtUpdateOneScheduler = `` /* 165-byte string literal not displayed */

	/*query all schedulers.*/
	StmtFindAllScheduler = `` /* 200-byte string literal not displayed */

	/*query Last Insert Id*/
	StmtFindLastInsertId = `
	SELECT 
		max(id)
	FROM scheduler
	WHERE
		filename = %q
	AND 
		interval_ms = %d`
)
View Source
const (
	/*add a new backends.*/
	StmtAddOneServers = `
	INSERT 
	INTO 
		mysql_servers(
			hostgroup_id,
			hostname,
			port,
			max_connections
		) 
	VALUES(%d,%q,%d,%d)`

	/*delete a backend*/
	StmtDeleteOneServers = `
	DELETE 
	FROM 
		mysql_servers 
	WHERE 
		hostgroup_id=%d 
	AND hostname=%q 
	AND port=%d`

	/*update a backends*/
	StmtUpdateOneServer = `` /* 231-byte string literal not displayed */

	/*list all mysql_servers*/
	StmtFindAllServer = `` /* 474-byte string literal not displayed */

)
View Source
const (
	/*add a new users*/
	StmtAddOneUser = `
	INSERT INTO 
		mysql_users(username,password,default_hostgroup,default_schema)
	VALUES(%q,%q,%d,%q)`

	/*delete a user*/
	StmtDeleteOneUser = `
	DELETE FROM 
		mysql_users 
	WHERE 
		username = %q
	AND
		backend = %d
	AND
		frontend = %d
	`

	/*list all users*/
	StmtFindAllUserInfo = `` /* 358-byte string literal not displayed */

	/*update a users*/
	StmtUpdateOneUser = `` /* 304-byte string literal not displayed */

)
View Source
const (
	StmtGlobalVariables   = `SHOW GLOBAL VARIABLES`
	StmtUpdateOneVariable = `
	UPDATE 
		global_variables 
	SET 
		variable_value=%q 
	WHERE variable_name = %q`
)
View Source
const (
	StmtMySQLStatus = `SHOW MYSQL STATUS`
)

Variables

This section is empty.

Functions

func LoadAdminVariablesToRuntime

func LoadAdminVariablesToRuntime(db *sql.DB) error

execute load admin variables to runtime.

func LoadMySQLVariablesToRuntime

func LoadMySQLVariablesToRuntime(db *sql.DB) error

execute load mysql variables to runtime.

func LoadQueryRulesToRuntime

func LoadQueryRulesToRuntime(db *sql.DB) error

execute load mysql query rules to runtime.

func LoadSchedulerToRuntime

func LoadSchedulerToRuntime(db *sql.DB) error

execute load schedulers to runtime.

func LoadServerToRuntime

func LoadServerToRuntime(db *sql.DB) error

execute load mysql servers to runtime.

func LoadUserToRuntime

func LoadUserToRuntime(db *sql.DB) error

execute load mysql users to runtime.

func ProxyFlushLogs

func ProxyFlushLogs(db *sql.DB) error

flush proxysql logs to file

func ProxyKill

func ProxyKill(db *sql.DB) error

kill child process.

func ProxyPause

func ProxyPause(db *sql.DB) error

pause proxysql

func ProxyReadOnly

func ProxyReadOnly(db *sql.DB) error

set proxysql to readonly mode.

func ProxyReadWrite

func ProxyReadWrite(db *sql.DB) error

set proxysql to readwrite mode.

func ProxyRestart

func ProxyRestart(db *sql.DB) error

restart proxysql process.

func ProxyResume

func ProxyResume(db *sql.DB) error

resume proxysql

func ProxyShutdown

func ProxyShutdown(db *sql.DB) error

shutdown proxysql

func ProxyStart

func ProxyStart(db *sql.DB) error

start proxysql child process.

func ProxyStop

func ProxyStop(db *sql.DB) error

stop proxysql child process.

func SaveAdminVariablesToDisk

func SaveAdminVariablesToDisk(db *sql.DB) error

execute save admin variables to disk.

func SaveMySQLVariablesToDisk

func SaveMySQLVariablesToDisk(db *sql.DB) error

execute save mysql variables to runtime.

func SaveQueryRulesToDisk

func SaveQueryRulesToDisk(db *sql.DB) error

execute save mysql query rules to disk.

func SaveSchedulerToDisk

func SaveSchedulerToDisk(db *sql.DB) error

execute save schedulers to disk.

func SaveServerToDisk

func SaveServerToDisk(db *sql.DB) error

execute save mysql servers to disk.

func SaveUserToDisk

func SaveUserToDisk(db *sql.DB) error

execute save mysql users to disk.

func UpdateOneConfig

func UpdateOneConfig(db *sql.DB, var_name string, var_value string) error

Types

type Conn

type Conn struct {
	Addr      string
	Port      uint64
	User      string
	Password  string
	Database  string
	Charset   string
	Collation string
	DBI       string
	Retry     uint64
}

connect proxysql use admin user.

func NewConn

func NewConn(addr string, port uint64, user string, password string) (*Conn, error)

func (*Conn) CloseConn

func (ps *Conn) CloseConn(db *sql.DB) error

close connection.

func (*Conn) MakeDBI

func (ps *Conn) MakeDBI()

func (*Conn) OpenConn

func (ps *Conn) OpenConn() (*sql.DB, error)

func (*Conn) SetCharset

func (ps *Conn) SetCharset(charset string)

set character set .such as : utf8

func (*Conn) SetCollation

func (ps *Conn) SetCollation(collation string)

set collation.such as : utf8_general_ci

func (*Conn) SetRetry

func (ps *Conn) SetRetry(retry uint64)

set retrys.

type PsStatus

type PsStatus struct {
	Active_Transactions          int64 `db:"Active_Transactions" json:"Active_Transactions"`
	Backend_query_time_nsec      int64 `db:"Backend_query_time_nsec" json:"Backend_query_time_nsec"`
	Client_Connections_aborted   int64 `db:"Client_Connections_aborted" json:"Client_Connections_aborted"`
	Client_Connections_connected int64 `db:"Client_Connections_connected" json:"Client_Connections_connected"`
	Client_Connections_created   int64 `db:"Client_Connections_created" json:"Client_Connections_created"`
	Client_Connections_non_idle  int64 `db:"Client_Connections_non_idle" json:"Client_Connections_non_idle"`
	Com_autocommit               int64 `db:"Com_autocommit" json:"Com_autocommit"`
	Com_autocommit_filtered      int64 `db:"Com_autocommit_filtered" json:"Com_autocommit_filtered"`
	Com_commit                   int64 `db:"Com_commit" json:"Com_commit"`
	Com_commit_filtered          int64 `db:"Com_commit_filtered" json:"Com_commit_filtered"`
	Com_rollback                 int64 `db:"Com_rollback" json:"Com_rollback"`
	Com_rollback_filtered        int64 `db:"Com_rollback_filtered" json:"Com_rollback_filtered"`
	Com_stmt_close               int64 `db:"Com_stmt_close" json:"Com_stmt_close"`
	Com_stmt_execute             int64 `db:"Com_stmt_execute" json:"Com_stmt_execute"`
	Com_stmt_prepare             int64 `db:"Com_stmt_prepare" json:"Com_stmt_prepare"`
	ConnPool_get_conn_failure    int64 `db:"ConnPool_get_conn_failure" json:"ConnPool_get_conn_failure"`
	ConnPool_get_conn_immediate  int64 `db:"ConnPool_get_conn_immediate" json:"ConnPool_get_conn_immediate"`
	ConnPool_get_conn_success    int64 `db:"ConnPool_get_conn_success" json:"ConnPool_get_conn_success"`
	ConnPool_memory_bytes        int64 `db:"ConnPool_memory_bytes" json:"ConnPool_memory_bytes"`
	MySQL_Monitor_Workers        int64 `db:"MySQL_Monitor_Workers" json:"MySQL_Monitor_Workers"`
	MySQL_Thread_Workers         int64 `db:"MySQL_Thread_Workers" json:"MySQL_Thread_Workers"`
	ProxySQL_Uptime              int64 `db:"ProxySQL_Uptime" json:"ProxySQL_Uptime"`
	Queries_backends_bytes_recv  int64 `db:"Queries_backends_bytes_recv" json:"Queries_backends_bytes_recv"`
	Queries_backends_bytes_sent  int64 `db:"Queries_backends_bytes_sent" json:"Queries_backends_bytes_sent"`
	Query_Cache_Entries          int64 `db:"Query_Cache_Entries" json:"Query_Cache_Entries"`
	Query_Cache_Memory_bytes     int64 `db:"Query_Cache_Memory_bytes" json:"Query_Cache_Memory_bytes"`
	Query_Cache_Purged           int64 `db:"Query_Cache_Purged" json:"Query_Cache_Purged"`
	Query_Cache_bytes_IN         int64 `db:"Query_Cache_bytes_IN" json:"Query_Cache_bytes_IN"`
	Query_Cache_bytes_OUT        int64 `db:"Query_Cache_bytes_OUT" json:"Query_Cache_bytes_OUT"`
	Query_Cache_count_GET        int64 `db:"Query_Cache_count_GET" json:"Query_Cache_count_GET"`
	Query_Cache_count_GET_OK     int64 `db:"Query_Cache_count_GET_OK" json:"Query_Cache_count_GET_OK"`
	Query_Cache_count_SET        int64 `db:"Query_Cache_count_SET" json:"Query_Cache_count_SET"`
	Query_Processor_time_nsec    int64 `db:"Query_Processor_time_nsec" json:"Query_Processor_time_nsec"`
	Questions                    int64 `db:"Questions" json:"Questions"`
	SQLite3_memory_bytes         int64 `db:"SQLite3_memory_bytes" json:"SQLite3_memory_bytes"`
	Server_Connections_aborted   int64 `db:"Server_Connections_aborted" json:"Server_Connections_aborted"`
	Server_Connections_connected int64 `db:"Server_Connections_connected" json:"Server_Connections_connected"`
	Server_Connections_created   int64 `db:"Server_Connections_created" json:"Server_Connections_created"`
	Servers_table_version        int64 `db:"Servers_table_version" json:"Servers_table_version"`
	Slow_queries                 int64 `db:"Slow_queries" json:"Slow_queries"`
	Stmt_Active_Total            int64 `db:"Stmt_Active_Total" json:"Stmt_Active_Total"`
	Stmt_Active_Unique           int64 `db:"Stmt_Active_Unique" json:"Stmt_Active_Unique"`
	Stmt_Max_Stmt_id             int64 `db:"Stmt_Max_Stmt_id" json:"Stmt_Max_Stmt_id"`
	Mysql_backend_buffers_bytes  int64 `db:"mysql_backend_buffers_bytes" json:"mysql_backend_buffers_bytes"`
	Mysql_frontend_buffers_bytes int64 `db:"mysql_frontend_buffers_bytes" json:"mysql_frontend_buffers_bytes"`
	Mysql_session_internal_bytes int64 `db:"mysql_session_internal_bytes" json:"mysql_session_internal_bytes"`
}

func (*PsStatus) GetProxySqlStatus

func (ps *PsStatus) GetProxySqlStatus(db *sql.DB) PsStatus

type QueryRules

type QueryRules struct {
	Rule_id               uint64 `db:"rule_id" json:"rule_id"`
	Active                uint64 `db:"active" json:"active"`
	Username              string `db:"username" json:"username"`
	Schemaname            string `db:"schemaname" json:"schemaname"`
	FlagIN                uint64 `db:"flagIN" json:"flagIN"`
	Client_addr           string `db:"client_addr" json:"client_addr"`
	Proxy_addr            string `db:"proxy_addr" json:"proxy_addr"`
	Proxy_port            string `db:"proxy_port" json:"proxy_port"`
	Digest                string `db:"digest" json:"digest"`
	Match_digest          string `db:"match_digest" json:"match_digest"`
	Match_pattern         string `db:"match_pattern" json:"match_pattern"`
	Negate_match_pattern  uint64 `db:"negate_match_pattern" json:"negate_match_pattern"`
	FlagOUT               string `db:"flagOUT" json:"flagOUT"`
	Replace_pattern       string `db:"replace_pattern" json:"replace_pattern"`
	Destination_hostgroup string `db:"destination_hostgroup" json:"destination_hostgroup"`
	Cache_ttl             string `db:"cache_ttl" json:"cache_ttl"`
	Reconnect             string `db:"reconnect" json:"reconnect"`
	Timeout               string `db:"timeout" json:"timeout"`
	Retries               string `db:"retries" json:"retries"`
	Delay                 string `db:"delay" json:"delay"`
	Mirror_flagOUT        string `db:"mirror_flagOUT" json:"mirror_flagOUT"`
	Mirror_hostgroup      string `db:"mirror_hostgroup" json:"mirror_hostgroup"`
	Error_msg             string `db:"error_msg" json:"error_msg"`
	Log                   string `db:"log" json:"log"`
	Apply                 uint64 `db:"apply" json:"apply"`
	Comment               string `db:"comment" json:"comment"`
}

func FindAllQr

func FindAllQr(db *sql.DB, limit uint64, skip uint64) ([]QueryRules, error)

select * from mysql_query_rules limit n offset n

func NewQr

func NewQr(username string) (*QueryRules, error)

new mysql query rules

func (*QueryRules) AddOneQr

func (qr *QueryRules) AddOneQr(db *sql.DB) error

add a new query rules.

func (*QueryRules) DeleteOneQr

func (qr *QueryRules) DeleteOneQr(db *sql.DB) error

delete a query rules.

func (*QueryRules) SetProxyPort

func (qr *QueryRules) SetProxyPort(proxy_port string)

set qr proxy_port

func (*QueryRules) SetQrActive

func (qr *QueryRules) SetQrActive(active uint64)

set qr active

func (*QueryRules) SetQrApply

func (qr *QueryRules) SetQrApply(apply uint64)

set qr apply

func (*QueryRules) SetQrCacheTTL

func (qr *QueryRules) SetQrCacheTTL(cache_ttl string)

set qr cache_ttl

func (*QueryRules) SetQrClientAddr

func (qr *QueryRules) SetQrClientAddr(client_addr string)

set qr client_addr

func (*QueryRules) SetQrDelay

func (qr *QueryRules) SetQrDelay(delay string)

set qr delay

func (*QueryRules) SetQrDestHostGroup

func (qr *QueryRules) SetQrDestHostGroup(destination_hostgroup string)

set qr destination_hostgroup

func (*QueryRules) SetQrDigest

func (qr *QueryRules) SetQrDigest(digest string)

set qr digest

func (*QueryRules) SetQrErrorMsg

func (qr *QueryRules) SetQrErrorMsg(error_msg string)

set qr error_msg

func (*QueryRules) SetQrFlagIN

func (qr *QueryRules) SetQrFlagIN(flag_in uint64)

set qr flagIN

func (*QueryRules) SetQrFlagOut

func (qr *QueryRules) SetQrFlagOut(flag_out string)

set qr flagout

func (*QueryRules) SetQrLog

func (qr *QueryRules) SetQrLog(log string)

set qr log

func (*QueryRules) SetQrMatchDigest

func (qr *QueryRules) SetQrMatchDigest(match_digest string)

set qr match_digest

func (*QueryRules) SetQrMatchPattern

func (qr *QueryRules) SetQrMatchPattern(match_pattern string)

set qr match_pattern

func (*QueryRules) SetQrMirrorFlagOUT

func (qr *QueryRules) SetQrMirrorFlagOUT(mirror_flagout string)

set qr mirror_flagout

func (*QueryRules) SetQrMirrorHostgroup

func (qr *QueryRules) SetQrMirrorHostgroup(mirror_hostgroup string)

set qr mirror_hostgroup

func (*QueryRules) SetQrNegateMatchPattern

func (qr *QueryRules) SetQrNegateMatchPattern(negate_match_pattern uint64)

set qr mnegate_match_pattern

func (*QueryRules) SetQrProxyAddr

func (qr *QueryRules) SetQrProxyAddr(proxy_addr string)

set qr proxy_addr

func (*QueryRules) SetQrReconnect

func (qr *QueryRules) SetQrReconnect(reconnect string)

set qr reconnect

func (*QueryRules) SetQrReplacePattern

func (qr *QueryRules) SetQrReplacePattern(replace_pattern string)

set qr replace_pattern

func (*QueryRules) SetQrRetries

func (qr *QueryRules) SetQrRetries(retries string)

set qr retries

func (*QueryRules) SetQrRuleid

func (qr *QueryRules) SetQrRuleid(rule_id uint64)

set qr rule_id

func (*QueryRules) SetQrSchemaname

func (qr *QueryRules) SetQrSchemaname(schema_name string)

set qr schemaname

func (*QueryRules) SetQrTimeOut

func (qr *QueryRules) SetQrTimeOut(timeout string)

set qr timeout

func (*QueryRules) UpdateOneQrInfo

func (qr *QueryRules) UpdateOneQrInfo(db *sql.DB) error

update a query rules.

type ReplicationHostgroup

type ReplicationHostgroup struct {
	WriterHostgroup uint64 `json:"writer_hostgroup" db:"writer_hostgroup"`
	ReaderHostgroup uint64 `json:"reader_hostgroup" db:"reader_hostgroup"`
	Comment         string `json:"comment" db:"comment"`
}

func NewRHG

func NewRHG(whg uint64, rhg uint64) (*ReplicationHostgroup, error)

new replication hostgroup instance

func QueryAllRHG

func QueryAllRHG(db *sql.DB, limit uint64, skip uint64) ([]ReplicationHostgroup, error)

list all mysql_servers

func (*ReplicationHostgroup) AddOneRHG

func (rhg *ReplicationHostgroup) AddOneRHG(db *sql.DB) error

add one new replication hostgroup

func (*ReplicationHostgroup) DeleteOneRHG

func (rhg *ReplicationHostgroup) DeleteOneRHG(db *sql.DB) error

delete one replication hostgroup

func (*ReplicationHostgroup) SetComment

func (rhg *ReplicationHostgroup) SetComment(comment string)

set comment

func (*ReplicationHostgroup) SetReaderHostGroup

func (rhg *ReplicationHostgroup) SetReaderHostGroup(reader uint64)

set reader hostgroup

func (*ReplicationHostgroup) SetWriterHostGroup

func (rhg *ReplicationHostgroup) SetWriterHostGroup(writer uint64)

set writer hostgroup

func (*ReplicationHostgroup) UpdateOneRHG

func (rhg *ReplicationHostgroup) UpdateOneRHG(db *sql.DB) error

update one replication hostgroup

type Schedulers

type Schedulers struct {
	Id         int64  `json:"id" db:"id"`
	Active     int64  `json:"active" db:"active"`
	IntervalMs int64  `json:"interval_ms" db:"interval_ms"`
	FileName   string `json:"filename" db:"filename"`
	Arg1       string `json:"arg1" db:"arg1"`
	Arg2       string `json:"arg2" db:"arg2"`
	Arg3       string `json:"arg3" db:"arg3"`
	Arg4       string `json:"arg4" db:"arg4"`
	Arg5       string `json:"arg5" db:"arg5"`
	Comment    string `json:"comment" db:"comment"`
}

func FindAllSchedulerInfo

func FindAllSchedulerInfo(db *sql.DB, limit uint64, skip uint64) ([]Schedulers, error)

query all schedulers

func NewSch

func NewSch(filename string, interval_ms int64) (*Schedulers, error)

new NewSch

func (*Schedulers) AddOneScheduler

func (schld *Schedulers) AddOneScheduler(db *sql.DB) error

add a new scheduler

func (*Schedulers) DeleteOneScheduler

func (schld *Schedulers) DeleteOneScheduler(db *sql.DB) error

delete a scheduler

func (*Schedulers) SetSchedulerActive

func (sched *Schedulers) SetSchedulerActive(active int64)

Set Scheduler Active status

func (*Schedulers) SetSchedulerArg1

func (sched *Schedulers) SetSchedulerArg1(arg1 string)

Set Scheduler all Args

func (*Schedulers) SetSchedulerArg2

func (sched *Schedulers) SetSchedulerArg2(arg2 string)

func (*Schedulers) SetSchedulerArg3

func (sched *Schedulers) SetSchedulerArg3(arg3 string)

func (*Schedulers) SetSchedulerArg4

func (sched *Schedulers) SetSchedulerArg4(arg4 string)

func (*Schedulers) SetSchedulerArg5

func (sched *Schedulers) SetSchedulerArg5(arg5 string)

func (*Schedulers) SetSchedulerId

func (sched *Schedulers) SetSchedulerId(id int64)

Set Scheduler id

func (*Schedulers) SetSchedulerIntervalMs

func (sched *Schedulers) SetSchedulerIntervalMs(interval_ms int64)

Set scheduler interval_ms

func (*Schedulers) UpdateOneSchedulerInfo

func (schld *Schedulers) UpdateOneSchedulerInfo(db *sql.DB) error

update a scheduler.

type Servers

type Servers struct {
	HostGroupId       uint64 `db:"hostgroup_id,omitempty" json:"hostgroup_id"`
	HostName          string `db:"hostname" json:"hostname"`
	Port              uint64 `db:"port" json:"port"`
	Status            string `db:"status" json:"status"`
	Weight            uint64 `db:"weight" json:"weight"`
	Compression       uint64 `db:"compression" json:"compression"`
	MaxConnections    uint64 `db:"max_connections" json:"max_connections"`
	MaxReplicationLag uint64 `db:"max_replication_lag" json:"max_replication_lag"`
	UseSsl            uint64 `db:"use_ssl" json:"use_ssl"`
	MaxLatencyMs      uint64 `db:"max_latency_ms" json:"max_latency_ms"`
	Comment           string `db:"comment" json:"comment"`
}

func FindAllServerInfo

func FindAllServerInfo(db *sql.DB, limit uint64, skip uint64) ([]Servers, error)

list all mysql_servers

func NewServer

func NewServer(hostgroup_id uint64, hostname string, port uint64) (*Servers, error)

init a new servers.

func (*Servers) AddOneServers

func (srvs *Servers) AddOneServers(db *sql.DB) error

add a new backend

func (*Servers) DeleteOneServers

func (srvs *Servers) DeleteOneServers(db *sql.DB) error

delete a backend

func (*Servers) SetServerCompression

func (srvs *Servers) SetServerCompression(compression uint64)

set servers compression

func (*Servers) SetServerMaxConnection

func (srvs *Servers) SetServerMaxConnection(max_connections uint64)

set servers max_connections

func (*Servers) SetServerMaxLatencyMs

func (srvs *Servers) SetServerMaxLatencyMs(max_latency_ms uint64)

set servers max_latency_ms

func (*Servers) SetServerMaxReplicationLag

func (srvs *Servers) SetServerMaxReplicationLag(max_replication_lag uint64)

set servers max_replication_lag

func (*Servers) SetServerStatus

func (srvs *Servers) SetServerStatus(status string)

set servers status

func (*Servers) SetServerUseSSL

func (srvs *Servers) SetServerUseSSL(use_ssl uint64)

set servers use_ssl

func (*Servers) SetServerWeight

func (srvs *Servers) SetServerWeight(weight uint64)

set servers weight

func (*Servers) SetServersComment

func (srvs *Servers) SetServersComment(comment string)

set servers comment

func (*Servers) UpdateOneServerInfo

func (srvs *Servers) UpdateOneServerInfo(db *sql.DB) error

更新后端服务全部信息

type Status

type Status struct {
	VariablesName string `db:"Variable_name" json:"Variable_name"`
	Value         int64  `db:"Value" json:"Value"`
}

type Users

type Users struct {
	Username              string `db:"username" json:"username"`
	Password              string `db:"password" json:"password"`
	Active                uint64 `db:"active" json:"active"`
	UseSsl                uint64 `db:"use_ssl" json:"use_ssl"`
	DefaultHostgroup      uint64 `db:"default_hostgroup" json:"default_hostgroup"`
	DefaultSchema         string `db:"default_schema" json:"default_schema"`
	SchemaLocked          uint64 `db:"schema_locked" json:"schema_locked"`
	TransactionPersistent uint64 `db:"transaction_persistent" json:"transaction_persistent"`
	FastForward           uint64 `db:"fast_forward" json:"fast_forward"`
	Backend               uint64 `db:"backend" json:"backend"`
	Frontend              uint64 `db:"frontend" json:"frontend"`
	MaxConnections        uint64 `db:"max_connections" json:"max_connections"`
}

func FindAllUserInfo

func FindAllUserInfo(db *sql.DB, limit uint64, skip uint64) ([]Users, error)

list all users.

func NewUser

func NewUser(username string, password string, default_hostgroup uint64, default_schema string) (*Users, error)

func (*Users) AddOneUser

func (users *Users) AddOneUser(db *sql.DB) error

add a new user.

func (*Users) DeleteOneUser

func (users *Users) DeleteOneUser(db *sql.DB) error

delete a user.

func (*Users) SetBackend

func (users *Users) SetBackend(backend uint64)

set backend

func (*Users) SetFastForward

func (users *Users) SetFastForward(fast_forward uint64)

set fast_forward

func (*Users) SetFrontend

func (users *Users) SetFrontend(frontend uint64)

set fronted

func (*Users) SetMaxConnections

func (users *Users) SetMaxConnections(max_connections uint64)

set max_connections

func (*Users) SetSchemaLocked

func (users *Users) SetSchemaLocked(schema_locked uint64)

set users SchemaLocked

func (*Users) SetTransactionPersistent

func (users *Users) SetTransactionPersistent(transaction_persistent uint64)

set users transaction_persistent

func (*Users) SetUseSSL

func (users *Users) SetUseSSL(use_ssl uint64)

Set users UseSSL

func (*Users) SetUserActive

func (users *Users) SetUserActive(active uint64)

set user active/disactive

func (*Users) UpdateOneUserInfo

func (users *Users) UpdateOneUserInfo(db *sql.DB) error

update a user.

type Variables

type Variables struct {
	VariablesName string `db:"Variable_name" json:"variable_name"`
	Value         string `db:"Value" json:"variable_value"`
}

func GetConfig

func GetConfig(db *sql.DB) ([]Variables, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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