Documentation ¶
Overview ¶
Package common common library func for lightning
Index ¶
- Variables
- func Caller() string
- func FlushReplicationInfo()
- func GetFunctionName() string
- func GoldenDiff(f func(), name string, update *bool) error
- func ListPlugin()
- func LoadMasterInfo()
- func LogIfError(err error, format string, v ...interface{})
- func LogIfWarn(err error, format string, v ...interface{})
- func ParseConfig()
- func PrintConfiguration()
- func PrintMasterInfo()
- func SyncReplicationInfo()
- func TimeOffset(timezone string) int
- func Verbose(format string, a ...interface{})
- func VerboseVerbose(format string, a ...interface{})
- type ChangeMaster
- type Configuration
- type Filters
- type GlobalConfig
- type MySQL
- type Rebuild
Constants ¶
This section is empty.
Variables ¶
var Config = Configuration{
gConfig,
mConfig,
fConfig,
rConfig,
}
Config global config variable
var Log *logs.BeeLogger
Log 使用 beego 的 log 库
var MasterInfo = ChangeMaster{
MasterPort: 3306,
ServerID: 11,
ServerType: "mysql",
}
MasterInfo replication status info
Functions ¶
func Caller ¶
func Caller() string
Caller returns the caller of the function that called it :) https://stackoverflow.com/questions/35212985/is-it-possible-get-information-about-caller-function-in-golang
func GoldenDiff ¶
GoldenDiff 从 gofmt 学来的测试方法 https://medium.com/soon-london/testing-with-golden-files-in-go-7fccc71c43d3
func LogIfError ¶
LogIfError 简化if err != nil 打 Error 日志代码长度
func SyncReplicationInfo ¶
func SyncReplicationInfo()
SyncReplicationInfo sync replication status into master.info
Types ¶
type ChangeMaster ¶
type ChangeMaster struct { MasterHost string `yaml:"master_host"` MasterUser string `yaml:"master_user"` MasterPassword string `yaml:"master_password"` MasterPort int `yaml:"master_port"` MasterLogFile string `yaml:"master_log_file"` MasterLogPos int64 `yaml:"master_log_pos"` ExecutedGTIDSet string `yaml:"executed_gtid_set"` AutoPosition bool `yaml:"auto_position"` UntilLogFile string `yaml:"until_log_file"` UntilLogPos int64 `yaml:"until_log_pos"` UntilBeforeGTIDs string `yaml:"until_before_gtids"` UntilAfterGTIDs string `yaml:"until_after_gtids"` SecondsBehindMaster int64 `yaml:"seconds_behind_master"` // last execute event timestamp ServerID uint32 `yaml:"server-id"` ServerType string `yaml:"server-type"` // mysql, mariadb }
ChangeMaster change master info
func ShowMasterStatus ¶
func ShowMasterStatus(masterInfo ChangeMaster) ChangeMaster
ShowMasterStatus execute `show master status`, get master info
type Configuration ¶
type Configuration struct { Global GlobalConfig `yaml:"global"` MySQL MySQL `yaml:"mysql"` Filters Filters `yaml:"filters"` Rebuild Rebuild `yaml:"rebuild"` }
Configuration config sections
type Filters ¶
type Filters struct { Tables []string `yaml:"tables"` // replication_wild_do_tables format IgnoreTables []string `yaml:"ignore-tables"` // replicate_wild_ignore_tables format EventType []string `yaml:"event-types"` // insert, update, delete ThreadID int `yaml:"thread-id"` ServerID int `yaml:"server-id"` StartPosition uint32 `yaml:"start-position"` StopPosition uint32 `yaml:"stop-position"` StartDatetime string `yaml:"start-datetime"` StopDatetime string `yaml:"stop-datetime"` IncludeGTIDSet string `yaml:"include-gtid-set"` ExcludeGTIDSet string `yaml:"exclude-gtid-set"` StartTimestamp int64 `yaml:"-"` StopTimestamp int64 `yaml:"-"` }
Filters filters about event
type GlobalConfig ¶
type GlobalConfig struct { // 日志级别,这里使用了 beego 的 log 包 // [0:Emergency, 1:Alert, 2:Critical, 3:Error, 4:Warning, 5:Notice, 6:Informational, 7:Debug] LogLevel int `yaml:"log-level"` // 日志输出位置,默认日志输出到控制台 // 目前只支持['console', 'file']两种形式,如非console形式这里需要指定文件的路径,可以是相对路径 LogOutput string `yaml:"log-output"` Daemon bool `yaml:"daemon"` Charset string `yaml:"charset"` HexString bool `yaml:"hex-string"` // string, varchar 等数据是否使用 hex 转义,防止数据转换 CPU int `yaml:"cpu"` // CPU core limit Verbose bool `yaml:"verbose"` // more info to print VerboseVerbose bool `yaml:"verbose-verbose"` // more and more info to print TimeZone string `yaml:"time-zone"` // "UTC", "Asia/Shanghai" Location *time.Location `yaml:"-"` }
GlobalConfig global config
type MySQL ¶
type MySQL struct { BinlogFile []string `yaml:"binlog-file"` SchemaFile string `yaml:"schema-file"` MasterInfo string `yaml:"master-info"` ReplicateFromCurrentPosition bool `yaml:"replicate-from-current-position"` SyncInterval string `yaml:"sync-interval"` SyncDuration time.Duration `yaml:"-"` ReadTimeout string `yaml:"read-timeout"` RetryCount int `yaml:"retry-count"` Keyring string `yaml:"keyring"` }
MySQL binlog file location or streamer, if streamer use dsn format
type Rebuild ¶
type Rebuild struct { Plugin string `yaml:"plugin"` // Plugin name: sql, flashback, stat, lua, find CompleteInsert bool `yaml:"complete-insert"` ExtendedInsertCount int `yaml:"extended-insert-count"` IgnoreColumns []string `yaml:"ignore-columns"` Replace bool `yaml:"replace"` SleepInterval string `yaml:"sleep-interval"` SleepDuration time.Duration `yaml:"-"` LuaScript string `yaml:"lua-script"` WithoutDBName bool `yaml:"without-db-name"` }
Rebuild rebuild plugins