github.com/pingcap/tiup@v1.15.1/components/dm/ansible/worker.go (about) 1 // Copyright 2020 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package ansible 15 16 // Config Copy from https://github.com/pingcap/dm/blob/21a6e6e580f2e911edbe2400241bd95de2f7ef43/dm/worker/config.go#L93 17 // remove some unconcern parts. 18 type Config struct { 19 LogLevel string `toml:"log-level" json:"log-level"` 20 LogFile string `toml:"log-file" json:"log-file"` 21 LogFormat string `toml:"log-format" json:"log-format"` 22 LogRotate string `toml:"log-rotate" json:"log-rotate"` 23 24 WorkerAddr string `toml:"worker-addr" json:"worker-addr"` 25 26 EnableGTID bool `toml:"enable-gtid" json:"enable-gtid"` 27 AutoFixGTID bool `toml:"auto-fix-gtid" json:"auto-fix-gtid"` 28 RelayDir string `toml:"relay-dir" json:"relay-dir"` 29 MetaDir string `toml:"meta-dir" json:"meta-dir"` 30 ServerID uint32 `toml:"server-id" json:"server-id"` 31 Flavor string `toml:"flavor" json:"flavor"` 32 Charset string `toml:"charset" json:"charset"` 33 34 // relay synchronous starting point (if specified) 35 RelayBinLogName string `toml:"relay-binlog-name" json:"relay-binlog-name"` 36 RelayBinlogGTID string `toml:"relay-binlog-gtid" json:"relay-binlog-gtid"` 37 38 SourceID string `toml:"source-id" json:"source-id"` 39 From DBConfig `toml:"from" json:"from"` 40 } 41 42 // DBConfig of db. 43 type DBConfig struct { 44 Host string `toml:"host" json:"host" yaml:"host"` 45 Port int `toml:"port" json:"port" yaml:"port"` 46 User string `toml:"user" json:"user" yaml:"user"` 47 Password string `toml:"password" json:"-" yaml:"password"` // omit it for privacy 48 MaxAllowedPacket *int `toml:"max-allowed-packet" json:"max-allowed-packet" yaml:"max-allowed-packet"` 49 } 50 51 // SourceConfig is the configuration for Worker 52 // ref: https://github.com/pingcap/dm/blob/3730a4e231091c5d65130d15a6c09a3b9fa3255e/dm/config/source_config.go#L51 53 type SourceConfig struct { 54 EnableGTID bool `yaml:"enable-gtid" toml:"enable-gtid" json:"enable-gtid"` 55 AutoFixGTID bool `yaml:"auto-fix-gtid" toml:"auto-fix-gtid" json:"auto-fix-gtid"` 56 RelayDir string `yaml:"relay-dir" toml:"relay-dir" json:"relay-dir"` 57 MetaDir string `yaml:"meta-dir" toml:"meta-dir" json:"meta-dir"` 58 Flavor string `yaml:"flavor" toml:"flavor" json:"flavor"` 59 Charset string `yaml:"charset" toml:"charset" json:"charset"` 60 61 EnableRelay bool `yaml:"enable-relay" toml:"enable-relay" json:"enable-relay"` 62 // relay synchronous starting point (if specified) 63 RelayBinLogName string `yaml:"relay-binlog-name" toml:"relay-binlog-name" json:"relay-binlog-name"` 64 RelayBinlogGTID string `yaml:"relay-binlog-gtid" toml:"relay-binlog-gtid" json:"relay-binlog-gtid"` 65 66 SourceID string `yaml:"source-id" toml:"source-id" json:"source-id"` 67 From DBConfig `yaml:"from" toml:"from" json:"from"` 68 } 69 70 // ToSource generate the SourceConfig for DM 2.0 71 func (c *Config) ToSource() (source *SourceConfig) { 72 source = &SourceConfig{ 73 EnableGTID: c.EnableGTID, 74 AutoFixGTID: c.AutoFixGTID, 75 RelayDir: c.RelayDir, 76 MetaDir: c.MetaDir, 77 Flavor: c.Flavor, 78 // EnableRelay: 79 RelayBinLogName: c.RelayBinLogName, 80 RelayBinlogGTID: c.RelayBinlogGTID, 81 SourceID: c.SourceID, 82 From: c.From, 83 } 84 85 return 86 }