common

package
v0.0.0-...-744e9a0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package common common library func for lightning

Index

Constants

This section is empty.

Variables

View Source
var Config = Configuration{
	gConfig,
	mConfig,
	fConfig,
	rConfig,
}

Config global config variable

Log 使用 beego 的 log 库

View Source
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 FlushReplicationInfo

func FlushReplicationInfo()

FlushReplicationInfo flush master.info

func GetFunctionName

func GetFunctionName() string

GetFunctionName 获取调当前函数名

func GoldenDiff

func GoldenDiff(f func(), name string, update *bool) error

GoldenDiff 从 gofmt 学来的测试方法 https://medium.com/soon-london/testing-with-golden-files-in-go-7fccc71c43d3

func ListPlugin

func ListPlugin()

ListPlugin list support plugin name and description

func LoadMasterInfo

func LoadMasterInfo()

LoadMasterInfo get master.info from file

func LogIfError

func LogIfError(err error, format string, v ...interface{})

LogIfError 简化if err != nil 打 Error 日志代码长度

func LogIfWarn

func LogIfWarn(err error, format string, v ...interface{})

LogIfWarn 简化if err != nil 打 Warn 日志代码长度

func ParseConfig

func ParseConfig()

ParseConfig parse configuration

func PrintConfiguration

func PrintConfiguration()

PrintConfiguration for `-print-config` flag

func PrintMasterInfo

func PrintMasterInfo()

PrintMasterInfo for `-print-master-info` flag

func SyncReplicationInfo

func SyncReplicationInfo()

SyncReplicationInfo sync replication status into master.info

func TimeOffset

func TimeOffset(timezone string) int

TimeOffset timezone offset seconds

func Verbose

func Verbose(format string, a ...interface{})

Verbose ...

func VerboseVerbose

func VerboseVerbose(format string, a ...interface{})

VerboseVerbose ...

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

Jump to

Keyboard shortcuts

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