config

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 16 Imported by: 14

Documentation

Index

Constants

View Source
const (
	ModeAll       = "all"
	ModeFull      = "full"
	ModeIncrement = "incremental"
)

task modes

View Source
const (
	GHOST = "gh-ost"
	PT    = "pt"
)

Online DDL Scheme

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdName

type CmdName string

CmdName represents name for binary

const (
	CmdLoader CmdName = "loader"
	CmdSyncer CmdName = "syncer"
)

binary names

type DBConfig

type DBConfig struct {
	Host     string `toml:"host" json:"host" yaml:"host"`
	Port     int    `toml:"port" json:"port" yaml:"port"`
	User     string `toml:"user" json:"user" yaml:"user"`
	Password string `toml:"password" json:"-" yaml:"password"` // omit it for privacy
}

DBConfig is the DB configuration.

func (*DBConfig) Decode

func (db *DBConfig) Decode(data string) error

Decode loads config from file data

func (*DBConfig) Toml

func (db *DBConfig) Toml() (string, error)

Toml returns TOML format representation of config

type LoaderConfig

type LoaderConfig struct {
	PoolSize int    `yaml:"pool-size" toml:"pool-size" json:"pool-size"`
	Dir      string `yaml:"dir" toml:"dir" json:"dir"`
}

LoaderConfig represents loader process unit's specific config

func (*LoaderConfig) UnmarshalYAML

func (m *LoaderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements Unmarshaler.UnmarshalYAML

type Meta

type Meta struct {
	BinLogName string `yaml:"binlog-name"`
	BinLogPos  uint32 `yaml:"binlog-pos"`
}

Meta represents binlog's meta pos NOTE: refine to put these config structs into pkgs NOTE: now, syncer does not support GTID mode and which is supported by relay

func (*Meta) Verify

func (m *Meta) Verify() error

Verify does verification on configs

type MySQLInstance

type MySQLInstance struct {
	// it represents a MySQL/MariaDB instance or a replica group
	SourceID           string   `yaml:"source-id"`
	Meta               *Meta    `yaml:"meta"`
	FilterRules        []string `yaml:"filter-rules"`
	ColumnMappingRules []string `yaml:"column-mapping-rules"`
	RouteRules         []string `yaml:"route-rules"`
	BWListName         string   `yaml:"black-white-list"`

	MydumperConfigName string          `yaml:"mydumper-config-name"`
	Mydumper           *MydumperConfig `yaml:"mydumper"`
	LoaderConfigName   string          `yaml:"loader-config-name"`
	Loader             *LoaderConfig   `yaml:"loader"`
	SyncerConfigName   string          `yaml:"syncer-config-name"`
	Syncer             *SyncerConfig   `yaml:"syncer"`
}

MySQLInstance represents a sync config of a MySQL instance

func (*MySQLInstance) Verify

func (m *MySQLInstance) Verify() error

Verify does verification on configs

type MydumperConfig

type MydumperConfig struct {
	MydumperPath  string `yaml:"mydumper-path" toml:"mydumper-path" json:"mydumper-path"`    // mydumper binary path
	Threads       int    `yaml:"threads" toml:"threads" json:"threads"`                      // -t, --threads
	ChunkFilesize int64  `yaml:"chunk-filesize" toml:"chunk-filesize" json:"chunk-filesize"` // -F, --chunk-filesize
	SkipTzUTC     bool   `yaml:"skip-tz-utc" toml:"skip-tz-utc" json:"skip-tz-utc"`          // --skip-tz-utc
	ExtraArgs     string `yaml:"extra-args" toml:"extra-args" json:"extra-args"`             // other extra args

}

MydumperConfig represents mydumper process unit's specific config

func (*MydumperConfig) UnmarshalYAML

func (m *MydumperConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements Unmarshaler.UnmarshalYAML

type SubTaskConfig

type SubTaskConfig struct {

	// when in sharding, multi dm-workers do one task
	IsSharding      bool   `toml:"is-sharding" json:"is-sharding"`
	OnlineDDLScheme string `toml:"online-ddl-scheme" json:"online-ddl-scheme"`

	// handle schema/table name mode, and only for schema/table name/pattern
	// if case insensitive, we would convert schema/table name/pattern to lower case
	CaseSensitive bool `toml:"case-sensitive" json:"case-sensitive"`

	Name string `toml:"name" json:"name"`
	Mode string `toml:"mode" json:"mode"`
	// it represents a MySQL/MariaDB instance or a replica group
	SourceID         string `toml:"source-id" json:"source-id"`
	ServerID         int    `toml:"server-id" json:"server-id"`
	Flavor           string `toml:"flavor" json:"flavor"`
	MetaSchema       string `toml:"meta-schema" json:"meta-schema"`
	RemoveMeta       bool   `toml:"remove-meta" json:"remove-meta"`
	DisableHeartbeat bool   `toml:"disable-heartbeat" json:"disable-heartbeat"` //  deprecated, use !enable-heartbeat instead
	EnableHeartbeat  bool   `toml:"enable-heartbeat" json:"enable-heartbeat"`
	Meta             *Meta  `toml:"meta" json:"meta"`
	Timezone         string `toml:"timezone" josn:"timezone"`

	BinlogType string `toml:"binlog-type" json:"binlog-type"`
	// RelayDir get value from dm-worker config
	RelayDir string   `toml:"relay-dir" json:"relay-dir"`
	From     DBConfig `toml:"from" json:"from"`
	To       DBConfig `toml:"to" json:"to"`

	RouteRules         []*router.TableRule   `toml:"route-rules" json:"route-rules"`
	FilterRules        []*bf.BinlogEventRule `toml:"filter-rules" json:"filter-rules"`
	ColumnMappingRules []*column.Rule        `toml:"mapping-rule" json:"mapping-rule"`
	BWList             *filter.Rules         `toml:"black-white-list" json:"black-white-list"`

	MydumperConfig // Mydumper configuration
	LoaderConfig   // Loader configuration
	SyncerConfig   // Syncer configuration

	// compatible with standalone dm unit
	LogLevel  string `toml:"log-level" json:"log-level"`
	LogFile   string `toml:"log-file" json:"log-file"`
	LogRotate string `toml:"log-rotate" json:"log-rotate"`

	PprofAddr  string `toml:"pprof-addr" json:"pprof-addr"`
	StatusAddr string `toml:"status-addr" json:"status-addr"`

	ConfigFile string `toml:"-" json:"config-file"`
	// contains filtered or unexported fields
}

SubTaskConfig is the configuration for SubTask

func NewSubTaskConfig

func NewSubTaskConfig() *SubTaskConfig

NewSubTaskConfig creates a new SubTaskConfig

func (*SubTaskConfig) Decode

func (c *SubTaskConfig) Decode(data string) error

Decode loads config from file data

func (*SubTaskConfig) DecodeFile

func (c *SubTaskConfig) DecodeFile(fpath string) error

DecodeFile loads and decodes config from file

func (*SubTaskConfig) Parse

func (c *SubTaskConfig) Parse(arguments []string) error

Parse parses flag definitions from the argument list.

func (*SubTaskConfig) SetupFlags

func (c *SubTaskConfig) SetupFlags(name CmdName)

SetupFlags setups flags for binary

func (*SubTaskConfig) String

func (c *SubTaskConfig) String() string

String returns the config's json string

func (*SubTaskConfig) Toml

func (c *SubTaskConfig) Toml() (string, error)

Toml returns TOML format representation of config

type SyncerConfig

type SyncerConfig struct {
	MetaFile    string `yaml:"meta-file" toml:"meta-file" json:"meta-file"` // meta filename, used only when load SubConfig directly
	WorkerCount int    `yaml:"worker-count" toml:"worker-count" json:"worker-count"`
	Batch       int    `yaml:"batch" toml:"batch" json:"batch"`
	MaxRetry    int    `yaml:"max-retry" toml:"max-retry" json:"max-retry"`

	// refine following configs to top level configs?
	AutoFixGTID      bool `yaml:"auto-fix-gtid" toml:"auto-fix-gtid" json:"auto-fix-gtid"`
	EnableGTID       bool `yaml:"enable-gtid" toml:"enable-gtid" json:"enable-gtid"`
	DisableCausality bool `yaml:"disable-detect" toml:"disable-detect" json:"disable-detect"`
	SafeMode         bool `yaml:"safe-mode" toml:"safe-mode" json:"safe-mode"`
	EnableANSIQuotes bool `yaml:"enable-ansi-quotes" toml:"enable-ansi-quotes" json:"enable-ansi-quotes"`
}

SyncerConfig represents syncer process unit's specific config

func (*SyncerConfig) UnmarshalYAML

func (m *SyncerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements Unmarshaler.UnmarshalYAML

type TaskConfig

type TaskConfig struct {
	*flag.FlagSet `yaml:"-"`

	Name       string `yaml:"name"`
	TaskMode   string `yaml:"task-mode"`
	IsSharding bool   `yaml:"is-sharding"`
	// we store detail status in meta
	// don't save configuration into it
	MetaSchema string `yaml:"meta-schema"`
	// remove meta from downstreaming database
	// now we delete checkpoint and online ddl information
	RemoveMeta       bool   `yaml:"remove-meta"`
	DisableHeartbeat bool   `yaml:"disable-heartbeat"` //  deprecated, use !enable-heartbeat instead
	EnableHeartbeat  bool   `yaml:"enable-heartbeat"`
	Timezone         string `yaml:"timezone"`

	// handle schema/table name mode, and only for schema/table name
	// if case insensitive, we would convert schema/table name to lower case
	CaseSensitive bool `yaml:"case-sensitive"`

	TargetDB *DBConfig `yaml:"target-database"`

	MySQLInstances []*MySQLInstance `yaml:"mysql-instances"`

	OnlineDDLScheme string `yaml:"online-ddl-scheme"`

	Routes         map[string]*router.TableRule   `yaml:"routes"`
	Filters        map[string]*bf.BinlogEventRule `yaml:"filters"`
	ColumnMappings map[string]*column.Rule        `yaml:"column-mappings"`
	BWList         map[string]*filter.Rules       `yaml:"black-white-list"`

	Mydumpers map[string]*MydumperConfig `yaml:"mydumpers"`
	Loaders   map[string]*LoaderConfig   `yaml:"loaders"`
	Syncers   map[string]*SyncerConfig   `yaml:"syncers"`
}

TaskConfig is the configuration for Task

func NewTaskConfig

func NewTaskConfig() *TaskConfig

NewTaskConfig creates a TaskConfig

func (*TaskConfig) Decode

func (c *TaskConfig) Decode(data string) error

Decode loads config from file data

func (*TaskConfig) DecodeFile

func (c *TaskConfig) DecodeFile(fpath string) error

DecodeFile loads and decodes config from file

func (*TaskConfig) String

func (c *TaskConfig) String() string

String returns the config's yaml string

func (*TaskConfig) SubTaskConfigs

func (c *TaskConfig) SubTaskConfigs(sources map[string]DBConfig) ([]*SubTaskConfig, error)

SubTaskConfigs generates sub task configs

Jump to

Keyboard shortcuts

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