mysql

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBFromDSN

func NewDBFromDSN(opts *DSN) (db *sql.DB, err error)

Types

type ClusterManager

type ClusterManager interface {
	StartCluster(ctx context.Context) (err error)
	FindMaster(ctx context.Context) (masters []*DSN, err error)
	HealthyMembers(ctx context.Context) (members []*DSN)
}

type ConfigParser

type ConfigParser struct {
	Data map[string]*ConfigSection
	// contains filtered or unexported fields
}

func NewConfigParser

func NewConfigParser() (t *ConfigParser)

func (*ConfigParser) DeleteSection

func (t *ConfigParser) DeleteSection(sectionName string, section *ConfigSection)

func (*ConfigParser) GetSection

func (t *ConfigParser) GetSection(sectionName string) (section *ConfigSection, err error)

func (*ConfigParser) MergeSection

func (t *ConfigParser) MergeSection(section *ConfigSection) (err error)

func (*ConfigParser) Parse

func (t *ConfigParser) Parse(r io.Reader) (err error)

func (*ConfigParser) ParseFile

func (t *ConfigParser) ParseFile(configFile string) (err error)

func (*ConfigParser) SetSection

func (t *ConfigParser) SetSection(section *ConfigSection)

func (*ConfigParser) String

func (t *ConfigParser) String() (s string)

type ConfigSection

type ConfigSection struct {
	Name string
	Data map[string]string
	// contains filtered or unexported fields
}

func NewConfigSection

func NewConfigSection(name string) (t *ConfigSection)

func (*ConfigSection) Delete

func (t *ConfigSection) Delete(key string)

func (*ConfigSection) Get

func (t *ConfigSection) Get(key string) (s string, err error)

func (*ConfigSection) Set

func (t *ConfigSection) Set(key, value string)

func (*ConfigSection) String

func (t *ConfigSection) String() (s string)

type DSN

type DSN struct {
	Host     string
	Port     int
	Username string
	Password string
	DBName   string
}

type MGRSP

type MGRSP struct {
	// DataSrouces mysql instance data sources
	DataSrouces []*DSN
}

func (*MGRSP) FindMaster

func (t *MGRSP) FindMaster(ctx context.Context) (masters []*DSN, err error)

func (*MGRSP) HealthyMembers

func (t *MGRSP) HealthyMembers(ctx context.Context) (members []*DSN)

func (*MGRSP) StartCluster

func (t *MGRSP) StartCluster(ctx context.Context) (err error)

type ProxySQLAdmin added in v0.0.2

type ProxySQLAdmin struct {
	Conn *sql.DB
}

func NewProxySQLAdmin added in v0.0.2

func NewProxySQLAdmin(dsn DSN) (t *ProxySQLAdmin, err error)

func (*ProxySQLAdmin) AddMysqlServers added in v0.0.2

func (t *ProxySQLAdmin) AddMysqlServers(ctx context.Context, servers []*TableMysqlServers) (err error)

func (*ProxySQLAdmin) AddMysqlUsers added in v0.0.2

func (t *ProxySQLAdmin) AddMysqlUsers(ctx context.Context, users []*TableMysqlUsers) (err error)

func (*ProxySQLAdmin) AddProxySQLServers added in v0.0.2

func (t *ProxySQLAdmin) AddProxySQLServers(ctx context.Context, servers []*TableProxySQLServers) (err error)

func (*ProxySQLAdmin) Begin added in v0.0.2

func (t *ProxySQLAdmin) Begin(ctx context.Context) (err error)

func (*ProxySQLAdmin) Close added in v0.0.2

func (t *ProxySQLAdmin) Close() error

func (*ProxySQLAdmin) Commit added in v0.0.2

func (t *ProxySQLAdmin) Commit(ctx context.Context) (err error)

func (*ProxySQLAdmin) GetMysqlServers added in v0.0.2

func (t *ProxySQLAdmin) GetMysqlServers(ctx context.Context) (data []*TableMysqlServers, err error)

func (*ProxySQLAdmin) GetMysqlUsers added in v0.0.2

func (t *ProxySQLAdmin) GetMysqlUsers(ctx context.Context) (data []*TableMysqlUsers, err error)

func (*ProxySQLAdmin) GetProxySQLServers added in v0.0.2

func (t *ProxySQLAdmin) GetProxySQLServers(ctx context.Context) (data []*TableProxySQLServers, err error)

func (*ProxySQLAdmin) LoadAdminVariablesToRuntime added in v0.0.2

func (t *ProxySQLAdmin) LoadAdminVariablesToRuntime(ctx context.Context) (err error)

func (*ProxySQLAdmin) LoadMysqlServersToRuntime added in v0.0.2

func (t *ProxySQLAdmin) LoadMysqlServersToRuntime(ctx context.Context) (err error)

func (*ProxySQLAdmin) LoadMysqlUsersServersToRuntime added in v0.0.2

func (t *ProxySQLAdmin) LoadMysqlUsersServersToRuntime(ctx context.Context) (err error)

func (*ProxySQLAdmin) LoadProxySQLServersToRuntime added in v0.0.2

func (t *ProxySQLAdmin) LoadProxySQLServersToRuntime(ctx context.Context) (err error)

func (*ProxySQLAdmin) RemoveMysqlServer added in v0.0.2

func (t *ProxySQLAdmin) RemoveMysqlServer(ctx context.Context, hostname string) (err error)

func (*ProxySQLAdmin) RemoveMysqlUser added in v0.0.2

func (t *ProxySQLAdmin) RemoveMysqlUser(ctx context.Context, username string, frontend bool) (err error)

func (*ProxySQLAdmin) RemoveProxySQLServer added in v0.0.2

func (t *ProxySQLAdmin) RemoveProxySQLServer(ctx context.Context, hostname string) (err error)

func (*ProxySQLAdmin) Rollback added in v0.0.2

func (t *ProxySQLAdmin) Rollback(ctx context.Context) (err error)

type ProxySQLConfWriter

type ProxySQLConfWriter struct {
	Datadir                         string
	AdminVariables                  map[string]string
	MysqlVariables                  map[string]string
	MysqlServers                    []map[string]string
	MysqlUsers                      []map[string]string
	MysqlQueryRules                 []map[string]string
	Scheduler                       []map[string]string
	ProxySQLServers                 []map[string]string
	MysqlReplicationHostgroups      []map[string]string
	MysqlGroupReplicationHostgroups []map[string]string
}

func (*ProxySQLConfWriter) String

func (t *ProxySQLConfWriter) String() (conf string)

type SemiSync

type SemiSync struct {
	// DataSrouces mysql instance data sources
	DataSrouces    []*DSN
	DoubleMasterHA bool
}

func (*SemiSync) FindMaster

func (t *SemiSync) FindMaster(ctx context.Context) (masters []*DSN, err error)

func (*SemiSync) HealthyMembers

func (t *SemiSync) HealthyMembers(ctx context.Context) (members []*DSN)

func (*SemiSync) StartCluster

func (t *SemiSync) StartCluster(ctx context.Context) (err error)

type TableMysqlServers added in v0.0.2

type TableMysqlServers struct {
	HostGroupID       int    //hostgroup_id
	Hostname          string // hostname
	Port              int    `default:"3306"` //port
	GTIDPort          int    // gtid_port
	Status            string `default:"ONLINE"` //status
	Weight            int    `default:"1"`      // weight
	Compression       bool   //compression
	MaxConnections    int    `default:"200"` //max_connections
	MaxReplicationLag int    //max_replication_lag
	UseSSL            bool   //use_ssl
	MaxLatencyMS      int    // max_latency_ms
	Comment           string //comment
}

TableMysqlServers proxysql table mysql_servers define CREATE TABLE runtime_mysql_servers (

hostgroup_id INT CHECK (hostgroup_id>=0) NOT NULL DEFAULT 0,
hostname VARCHAR NOT NULL,
port INT CHECK (port >= 0 AND port <= 65535) NOT NULL DEFAULT 3306,
gtid_port INT CHECK ((gtid_port <> port OR gtid_port=0) AND gtid_port >= 0 AND gtid_port <= 65535) NOT NULL DEFAULT 0,
status VARCHAR CHECK (UPPER(status) IN ('ONLINE','SHUNNED','OFFLINE_SOFT', 'OFFLINE_HARD')) NOT NULL DEFAULT 'ONLINE',
weight INT CHECK (weight >= 0 AND weight <=10000000) NOT NULL DEFAULT 1,
compression INT CHECK (compression IN(0,1)) NOT NULL DEFAULT 0,
max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 1000,
max_replication_lag INT CHECK (max_replication_lag >= 0 AND max_replication_lag <= 126144000) NOT NULL DEFAULT 0,
use_ssl INT CHECK (use_ssl IN(0,1)) NOT NULL DEFAULT 0,
max_latency_ms INT UNSIGNED CHECK (max_latency_ms>=0) NOT NULL DEFAULT 0,
comment VARCHAR NOT NULL DEFAULT '',
PRIMARY KEY (hostgroup_id, hostname, port) )

type TableMysqlUsers added in v0.0.2

type TableMysqlUsers struct {
	Username              string         //username
	Password              string         //password
	Active                bool           `default:"true"` // active
	UseSSL                bool           //use_ssl
	DefaultHostgroup      int            // default_hostgroup
	DefaultSchema         sql.NullString //default_schema
	SchemaLocked          bool           //schema_locked
	TransactionPersistent bool           `default:"true"` //transaction_persistent
	FastForward           bool           //fast_forward
	Backend               bool           `default:"true"` //backend
	Frontend              bool           `default:"true"` //frontend
	MaxConnections        int            `default:"200"`  //max_connections
	Attributes            string         //attributes
	Comment               string         //comment
}

TableMysqlUsers proxysql table mysql_users CREATE TABLE mysql_users (

username VARCHAR NOT NULL,
password VARCHAR,
active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,
use_ssl INT CHECK (use_ssl IN (0,1)) NOT NULL DEFAULT 0,
default_hostgroup INT NOT NULL DEFAULT 0,
default_schema VARCHAR,
schema_locked INT CHECK (schema_locked IN (0,1)) NOT NULL DEFAULT 0,
transaction_persistent INT CHECK (transaction_persistent IN (0,1)) NOT NULL DEFAULT 1,
fast_forward INT CHECK (fast_forward IN (0,1)) NOT NULL DEFAULT 0,
backend INT CHECK (backend IN (0,1)) NOT NULL DEFAULT 1,
frontend INT CHECK (frontend IN (0,1)) NOT NULL DEFAULT 1,
max_connections INT CHECK (max_connections >=0) NOT NULL DEFAULT 10000,
attributes VARCHAR CHECK (JSON_VALID(attributes) OR attributes = '') NOT NULL DEFAULT '',
comment VARCHAR NOT NULL DEFAULT '',
PRIMARY KEY (username, backend),
UNIQUE (username, frontend))

type TableProxySQLServers added in v0.0.2

type TableProxySQLServers struct {
	Hostname string // hostname
	Port     int    `default:"6032"` // port
	Weight   int    // weight
	Comment  string // comment
}

TableProxySQLServers proxysql table proxysql_servers CREATE TABLE runtime_proxysql_servers (

hostname VARCHAR NOT NULL,
port INT NOT NULL DEFAULT 6032,
weight INT CHECK (weight >= 0) NOT NULL DEFAULT 0,
comment VARCHAR NOT NULL DEFAULT '',
PRIMARY KEY (hostname, port) )

Jump to

Keyboard shortcuts

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