Documentation ¶
Index ¶
- Constants
- func GetDB(migrationUuid string, mysql_uri string) (db *gosql.DB, exists bool, err error)
- func GetReplicationBinlogCoordinates(db *gosql.DB) (readBinlogCoordinates *BinlogCoordinates, ...)
- func GetReplicationLagFromSlaveStatus(informationSchemaDb *gosql.DB) (replicationLag time.Duration, err error)
- func GetTableColumns(db *gosql.DB, databaseName, tableName string) (*sql.ColumnList, *sql.ColumnList, error)
- type BinlogCoordinates
- func (this *BinlogCoordinates) DetachedCoordinates() (isDetached bool, detachedLogFile string, detachedLogPos string)
- func (this *BinlogCoordinates) DisplayString() string
- func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) FileNumber() (int, int)
- func (this *BinlogCoordinates) FileNumberDistance(other *BinlogCoordinates) int
- func (this *BinlogCoordinates) FileSmallerThan(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) IsEmpty() bool
- func (this *BinlogCoordinates) NextFileCoordinates() (BinlogCoordinates, error)
- func (this *BinlogCoordinates) PreviousFileCoordinates() (BinlogCoordinates, error)
- func (this *BinlogCoordinates) PreviousFileCoordinatesBy(offset int) (BinlogCoordinates, error)
- func (this *BinlogCoordinates) SmallerThan(other *BinlogCoordinates) bool
- func (this *BinlogCoordinates) SmallerThanOrEquals(other *BinlogCoordinates) bool
- func (this BinlogCoordinates) String() string
- type BinlogType
- type ConnectionConfig
- func (this *ConnectionConfig) Duplicate() *ConnectionConfig
- func (this *ConnectionConfig) DuplicateCredentials(key InstanceKey) *ConnectionConfig
- func (this *ConnectionConfig) Equals(other *ConnectionConfig) bool
- func (this *ConnectionConfig) GetDBUri(databaseName string) string
- func (this *ConnectionConfig) String() string
- func (this *ConnectionConfig) TLSConfig() *tls.Config
- func (this *ConnectionConfig) UseTLS(caCertificatePath, clientCertificate, clientKey string, allowInsecure bool) error
- type InstanceKey
- func (this *InstanceKey) DetachedKey() *InstanceKey
- func (this *InstanceKey) DisplayString() string
- func (this *InstanceKey) Equals(other *InstanceKey) bool
- func (this *InstanceKey) IsDetached() bool
- func (this *InstanceKey) IsValid() bool
- func (this *InstanceKey) ReattachedKey() *InstanceKey
- func (this *InstanceKey) SmallerThan(other *InstanceKey) bool
- func (this InstanceKey) String() string
- func (this *InstanceKey) StringCode() string
- type InstanceKeyMap
- func (this *InstanceKeyMap) AddKey(key InstanceKey)
- func (this *InstanceKeyMap) AddKeys(keys []InstanceKey)
- func (this *InstanceKeyMap) GetInstanceKeys() []InstanceKey
- func (this *InstanceKeyMap) HasKey(key InstanceKey) bool
- func (this *InstanceKeyMap) Len() int
- func (this *InstanceKeyMap) MarshalJSON() ([]byte, error)
- func (this *InstanceKeyMap) ReadCommaDelimitedList(list string) error
- func (this *InstanceKeyMap) ReadJson(jsonString string) error
- func (this *InstanceKeyMap) ToCommaDelimitedList() string
- func (this *InstanceKeyMap) ToJSON() (string, error)
- func (this *InstanceKeyMap) ToJSONString() string
- type ReplicationLagResult
Constants ¶
const ( MaxTableNameLength = 64 MaxReplicationPasswordLength = 32 MaxDBPoolConnections = 3 )
const DefaultInstancePort = 3306
const (
TLS_CONFIG_KEY = "ghost"
)
Variables ¶
This section is empty.
Functions ¶
func GetReplicationBinlogCoordinates ¶ added in v0.7.16
func GetReplicationBinlogCoordinates(db *gosql.DB) (readBinlogCoordinates *BinlogCoordinates, executeBinlogCoordinates *BinlogCoordinates, err error)
func GetReplicationLagFromSlaveStatus ¶ added in v1.0.48
func GetReplicationLagFromSlaveStatus(informationSchemaDb *gosql.DB) (replicationLag time.Duration, err error)
GetReplicationLagFromSlaveStatus returns replication lag for a given db; via SHOW SLAVE STATUS
func GetTableColumns ¶ added in v1.0.28
func GetTableColumns(db *gosql.DB, databaseName, tableName string) (*sql.ColumnList, *sql.ColumnList, error)
GetTableColumns reads column list from given table
Types ¶
type BinlogCoordinates ¶
type BinlogCoordinates struct { LogFile string LogPos int64 Type BinlogType }
BinlogCoordinates described binary log coordinates in the form of log file & log position.
func GetSelfBinlogCoordinates ¶
func GetSelfBinlogCoordinates(db *gosql.DB) (selfBinlogCoordinates *BinlogCoordinates, err error)
func ParseBinlogCoordinates ¶
func ParseBinlogCoordinates(logFileLogPos string) (*BinlogCoordinates, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306
func (*BinlogCoordinates) DetachedCoordinates ¶
func (this *BinlogCoordinates) DetachedCoordinates() (isDetached bool, detachedLogFile string, detachedLogPos string)
FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
func (*BinlogCoordinates) DisplayString ¶
func (this *BinlogCoordinates) DisplayString() string
DisplayString returns a user-friendly string representation of these coordinates
func (*BinlogCoordinates) Equals ¶
func (this *BinlogCoordinates) Equals(other *BinlogCoordinates) bool
Equals tests equality of this coordinate and another one.
func (*BinlogCoordinates) FileNumber ¶
func (this *BinlogCoordinates) FileNumber() (int, int)
FileNumber returns the numeric value of the file, and the length in characters representing the number in the filename. Example: FileNumber() of mysqld.log.000789 is (789, 6)
func (*BinlogCoordinates) FileNumberDistance ¶
func (this *BinlogCoordinates) FileNumberDistance(other *BinlogCoordinates) int
FileNumberDistance returns the numeric distance between this coordinate's file number and the other's. Effectively it means "how many rotates/FLUSHes would make these coordinates's file reach the other's"
func (*BinlogCoordinates) FileSmallerThan ¶
func (this *BinlogCoordinates) FileSmallerThan(other *BinlogCoordinates) bool
FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
func (*BinlogCoordinates) IsEmpty ¶
func (this *BinlogCoordinates) IsEmpty() bool
IsEmpty returns true if the log file is empty, unnamed
func (*BinlogCoordinates) NextFileCoordinates ¶
func (this *BinlogCoordinates) NextFileCoordinates() (BinlogCoordinates, error)
PreviousFileCoordinates guesses the filename of the previous binlog/relaylog
func (*BinlogCoordinates) PreviousFileCoordinates ¶
func (this *BinlogCoordinates) PreviousFileCoordinates() (BinlogCoordinates, error)
PreviousFileCoordinates guesses the filename of the previous binlog/relaylog
func (*BinlogCoordinates) PreviousFileCoordinatesBy ¶
func (this *BinlogCoordinates) PreviousFileCoordinatesBy(offset int) (BinlogCoordinates, error)
PreviousFileCoordinatesBy guesses the filename of the previous binlog/relaylog, by given offset (number of files back)
func (*BinlogCoordinates) SmallerThan ¶
func (this *BinlogCoordinates) SmallerThan(other *BinlogCoordinates) bool
SmallerThan returns true if this coordinate is strictly smaller than the other.
func (*BinlogCoordinates) SmallerThanOrEquals ¶
func (this *BinlogCoordinates) SmallerThanOrEquals(other *BinlogCoordinates) bool
SmallerThanOrEquals returns true if this coordinate is the same or equal to the other one. We do NOT compare the type so we can not use this.Equals()
func (BinlogCoordinates) String ¶
func (this BinlogCoordinates) String() string
String returns a user-friendly string representation of these coordinates
type ConnectionConfig ¶
type ConnectionConfig struct { Key InstanceKey User string Password string ImpliedKey *InstanceKey Timeout float64 // contains filtered or unexported fields }
ConnectionConfig is the minimal configuration required to connect to a MySQL server
func GetMasterConnectionConfigSafe ¶
func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool) (masterConfig *ConnectionConfig, err error)
func NewConnectionConfig ¶
func NewConnectionConfig() *ConnectionConfig
func (*ConnectionConfig) Duplicate ¶
func (this *ConnectionConfig) Duplicate() *ConnectionConfig
func (*ConnectionConfig) DuplicateCredentials ¶ added in v1.0.21
func (this *ConnectionConfig) DuplicateCredentials(key InstanceKey) *ConnectionConfig
DuplicateCredentials creates a new connection config with given key and with same credentials as this config
func (*ConnectionConfig) Equals ¶
func (this *ConnectionConfig) Equals(other *ConnectionConfig) bool
func (*ConnectionConfig) GetDBUri ¶
func (this *ConnectionConfig) GetDBUri(databaseName string) string
func (*ConnectionConfig) String ¶
func (this *ConnectionConfig) String() string
func (*ConnectionConfig) TLSConfig ¶ added in v1.0.48
func (this *ConnectionConfig) TLSConfig() *tls.Config
type InstanceKey ¶
InstanceKey is an instance indicator, identified by hostname and port
func GetInstanceKey ¶ added in v0.9.6
func GetInstanceKey(db *gosql.DB) (instanceKey *InstanceKey, err error)
GetInstanceKey reads hostname and port on given DB
func GetMasterKeyFromSlaveStatus ¶
func GetMasterKeyFromSlaveStatus(connectionConfig *ConnectionConfig) (masterKey *InstanceKey, err error)
func NewRawInstanceKey ¶
func NewRawInstanceKey(hostPort string) (*InstanceKey, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306
func ParseInstanceKey ¶ added in v1.1.1
func ParseInstanceKey(hostPort string) (*InstanceKey, error)
ParseInstanceKey will parse an InstanceKey from a string representation such as 127.0.0.1:3306. The port part is optional; there will be no name resolve
func (*InstanceKey) DetachedKey ¶
func (this *InstanceKey) DetachedKey() *InstanceKey
DetachedKey returns an instance key whose hostname is detached: invalid, but recoverable
func (*InstanceKey) DisplayString ¶
func (this *InstanceKey) DisplayString() string
DisplayString returns a user-friendly string representation of this key
func (*InstanceKey) Equals ¶
func (this *InstanceKey) Equals(other *InstanceKey) bool
Equals tests equality between this key and another key
func (*InstanceKey) IsDetached ¶
func (this *InstanceKey) IsDetached() bool
IsDetached returns 'true' when this hostname is logically "detached"
func (*InstanceKey) IsValid ¶
func (this *InstanceKey) IsValid() bool
IsValid uses simple heuristics to see whether this key represents an actual instance
func (*InstanceKey) ReattachedKey ¶
func (this *InstanceKey) ReattachedKey() *InstanceKey
ReattachedKey returns an instance key whose hostname is detached: invalid, but recoverable
func (*InstanceKey) SmallerThan ¶
func (this *InstanceKey) SmallerThan(other *InstanceKey) bool
SmallerThan returns true if this key is dictionary-smaller than another. This is used for consistent sorting/ordering; there's nothing magical about it.
func (InstanceKey) String ¶
func (this InstanceKey) String() string
String returns a user-friendly string representation of this key
func (*InstanceKey) StringCode ¶
func (this *InstanceKey) StringCode() string
StringCode returns an official string representation of this key
type InstanceKeyMap ¶
type InstanceKeyMap map[InstanceKey]bool
InstanceKeyMap is a convenience struct for listing InstanceKey-s
func NewInstanceKeyMap ¶
func NewInstanceKeyMap() *InstanceKeyMap
func (*InstanceKeyMap) AddKey ¶
func (this *InstanceKeyMap) AddKey(key InstanceKey)
AddKey adds a single key to this map
func (*InstanceKeyMap) AddKeys ¶
func (this *InstanceKeyMap) AddKeys(keys []InstanceKey)
AddKeys adds all given keys to this map
func (*InstanceKeyMap) GetInstanceKeys ¶
func (this *InstanceKeyMap) GetInstanceKeys() []InstanceKey
GetInstanceKeys returns keys in this map in the form of an array
func (*InstanceKeyMap) HasKey ¶
func (this *InstanceKeyMap) HasKey(key InstanceKey) bool
HasKey checks if given key is within the map
func (*InstanceKeyMap) Len ¶
func (this *InstanceKeyMap) Len() int
func (*InstanceKeyMap) MarshalJSON ¶
func (this *InstanceKeyMap) MarshalJSON() ([]byte, error)
MarshalJSON will marshal this map as JSON
func (*InstanceKeyMap) ReadCommaDelimitedList ¶
func (this *InstanceKeyMap) ReadCommaDelimitedList(list string) error
ReadJson unmarshalls a json into this map
func (*InstanceKeyMap) ReadJson ¶
func (this *InstanceKeyMap) ReadJson(jsonString string) error
ReadJson unmarshalls a json into this map
func (*InstanceKeyMap) ToCommaDelimitedList ¶
func (this *InstanceKeyMap) ToCommaDelimitedList() string
ToCommaDelimitedList will export this map in comma delimited format
func (*InstanceKeyMap) ToJSON ¶
func (this *InstanceKeyMap) ToJSON() (string, error)
ToJSON will marshal this map as JSON
func (*InstanceKeyMap) ToJSONString ¶
func (this *InstanceKeyMap) ToJSONString() string
ToJSONString will marshal this map as JSON
type ReplicationLagResult ¶ added in v1.0.6
type ReplicationLagResult struct { Key InstanceKey Lag time.Duration Err error }
func NewNoReplicationLagResult ¶ added in v1.0.35
func NewNoReplicationLagResult() *ReplicationLagResult
func (*ReplicationLagResult) HasLag ¶ added in v1.0.35
func (this *ReplicationLagResult) HasLag() bool