Documentation
¶
Index ¶
- Variables
- type Host
- func (h *Host) Comment() string
- func (h *Host) Compression() int
- func (h *Host) HostgroupID() int
- func (h *Host) Hostname() string
- func (h *Host) MaxConnections() int
- func (h *Host) MaxLatencyMS() int
- func (h *Host) MaxReplicationLag() int
- func (h *Host) Port() int
- func (h *Host) SetComment(c string) *Host
- func (h *Host) SetCompression(c int) *Host
- func (h *Host) SetHostgroupID(hg int) *Host
- func (h *Host) SetHostname(hn string) *Host
- func (h *Host) SetMaxConnections(m int) *Host
- func (h *Host) SetMaxLatencyMS(m int) *Host
- func (h *Host) SetMaxReplicationLag(m int) *Host
- func (h *Host) SetPort(p int) *Host
- func (h *Host) SetStatus(s string) *Host
- func (h *Host) SetUseSSL(u int) *Host
- func (h *Host) SetWeight(w int) *Host
- func (h *Host) Status() string
- func (h *Host) UseSSL() int
- func (h *Host) Valid() error
- func (h *Host) Weight() int
- type HostOpts
- func Comment(c string) HostOpts
- func Compression(c int) HostOpts
- func HostgroupID(h int) HostOpts
- func Hostname(h string) HostOpts
- func MaxConnections(c int) HostOpts
- func MaxLatencyMS(m int) HostOpts
- func MaxReplicationLag(m int) HostOpts
- func Port(p int) HostOpts
- func Status(s string) HostOpts
- func Table(t string) HostOpts
- func UseSSL(u int) HostOpts
- func Weight(w int) HostOpts
- type ProxySQL
- func (p *ProxySQL) AddHost(opts ...HostOpts) error
- func (p *ProxySQL) AddHosts(hosts ...*Host) error
- func (p *ProxySQL) All(opts ...HostOpts) ([]*Host, error)
- func (p *ProxySQL) Clear() error
- func (p *ProxySQL) Close()
- func (p *ProxySQL) Conn() *sql.DB
- func (p *ProxySQL) HostsLike(opts ...HostOpts) ([]*Host, error)
- func (p *ProxySQL) PersistChanges() error
- func (p *ProxySQL) Ping() error
- func (p *ProxySQL) RemoveHost(host *Host) error
- func (p *ProxySQL) RemoveHosts(hosts ...*Host) error
- func (p *ProxySQL) RemoveHostsLike(opts ...HostOpts) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrConfigBadTable = errors.New("Bad table value, must be one of 'mysql_servers', 'runtime_mysql_servers'") ErrConfigBadHostgroupID = errors.New("Bad hostgroup value, must be in [0, 2147483648]") ErrConfigBadPort = errors.New("Bad port value, must be in [0, 65535]") ErrConfigBadMaxConnections = errors.New("Bad max_connections value, must be > 0") ErrConfigBadStatus = errors.New("Bad status value, must be one of 'ONLINE','SHUNNED','OFFLINE_SOFT', 'OFFLINE_HARD'") ErrConfigBadWeight = errors.New("Bad weight value, must be > 0") ErrConfigBadCompression = errors.New("Bad compression value, must be in [0, 102400]") ErrConfigBadMaxReplicationLag = errors.New("Bad max_replication_lag value, must be in [0, 126144000]") ErrConfigBadUseSSL = errors.New("Bad use_ssl value, must be one of 0, 1") ErrConfigBadMaxLatencyMS = errors.New("Bad max_latency_ms value, must be > 0") ErrConfigDuplicateSpec = errors.New("Bad function call, a value was specified twice") ErrConfigNoHostname = errors.New("Bad hostname, must not be empty") )
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host represents a row in ProxySQL's mysql_servers config table
type HostOpts ¶
type HostOpts func(*hostQuery) *hostQuery
HostOpts is a type of function that is called with a hostQuery struct to specify a value in a query
func MaxConnections ¶
MaxConnections sets the 'max_connections' in a query
func MaxLatencyMS ¶
MaxLatencyMS sets the 'max_latency_ms' in a query
func MaxReplicationLag ¶
MaxReplicationLag sets the 'max_replication_lag' in a query
func Table ¶
Table sets the table in a query One of 'runtime_mysql_servers' or 'mysql_servers'
type ProxySQL ¶
type ProxySQL struct {
// contains filtered or unexported fields
}
func NewProxySQL ¶
NewProxySQL will create & return a pointer to a ProxySQL struct. It will fail and return an error if the call to `sql.Open` fails. This will really only fail if there is no memory left to create a connection struct
func (*ProxySQL) AddHost ¶
AddHost takes the configuration provided and inserts a host into ProxySQL with that configuration. This will return an error when a validation error of the configuration you specified occurs. This will propagate errors from sql.Exec as well
func (*ProxySQL) AddHosts ¶
AddHosts will insert each of the hosts into mysql_servers this will error if any of the hosts are not valid this will propagate error from sql.Exec
func (*ProxySQL) All ¶
All returns the state of the table that you specify This will error if configuration validation fails, you should only call this with All(Table("runtime_mysql_servers")) or just All() for "mysql_servers" This will also propagate error from sql.Query, sql.Rows.Scan, sql.Rows.Err
func (*ProxySQL) Clear ¶
Clear is a convenience function to clear configuration
func (*ProxySQL) Close ¶
func (p *ProxySQL) Close()
Close is a convenience function that calls the database/sql function on the underlying sql.DB connection
func (*ProxySQL) Conn ¶
Conn is a convenience function that returns the underlying sql.DB connection
func (*ProxySQL) HostsLike ¶
HostsLike will return all hosts that match the given configuration This will error on configuration validation failing This will also propagate error from sql.Query, sql.Rows.Scan, sql.Rows.Err
func (*ProxySQL) PersistChanges ¶
PersistChanges saves the mysql servers config to disk, and then loads it to the runtime. This must be called for ProxySQL's staged changes in the mysql_servers table to take effect and transfer to runtime_mysql_servers This propagates errors from sql.Exec
func (*ProxySQL) Ping ¶
Ping is a convenience function that calls the database/sql function on the underlying sql.DB connection
func (*ProxySQL) RemoveHost ¶
RemoveHost removes the host that matches the provided host's configuration exactly. This will propagate error from sql.Exec
func (*ProxySQL) RemoveHosts ¶
RemoveHosts is a convenience function that removes hosts in the given slice This will propagate error from RemoveHost, or from sql.Exec
Source Files
¶
- api.go
- host.go
- proxysql.go
- query.go
- util.go