mysql

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInstancePort = 3306
)

Variables

This section is empty.

Functions

func GetMaxReplicationLag

func GetMaxReplicationLag(baseConnectionConfig *ConnectionConfig, instanceKeyMap *InstanceKeyMap, replicationLagQuery string) (replicationLag time.Duration, err error)

GetMaxReplicationLag concurrently checks for replication lag on given list of instance keys, each via GetReplicationLag

func GetReplicationBinlogCoordinates added in v0.7.16

func GetReplicationBinlogCoordinates(db *gosql.DB) (readBinlogCoordinates *BinlogCoordinates, executeBinlogCoordinates *BinlogCoordinates, err error)

func GetReplicationLag

func GetReplicationLag(connectionConfig *ConnectionConfig, replicationLagQuery string) (replicationLag time.Duration, err error)

GetReplicationLag returns replication lag for a given connection config; either by explicit query or via SHOW SLAVE STATUS

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 corrdinate 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 corrdinate's file number and the other's. Effectively it means "how many roatets/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 BinlogType

type BinlogType int
const (
	BinaryLog BinlogType = iota
	RelayLog
)

type ConnectionConfig

type ConnectionConfig struct {
	Key      InstanceKey
	User     string
	Password string
}

ConnectionConfig is the minimal configuration required to connect to a MySQL server

func GetMasterConnectionConfigSafe

func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap) (masterConfig *ConnectionConfig, err error)

func NewConnectionConfig

func NewConnectionConfig() *ConnectionConfig

func (*ConnectionConfig) Duplicate

func (this *ConnectionConfig) Duplicate() *ConnectionConfig

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

type InstanceKey

type InstanceKey struct {
	Hostname string
	Port     int
}

InstanceKey is an instance indicator, identifued by hostname and port

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 ParseRawInstanceKeyLoose

func ParseRawInstanceKeyLoose(hostPort string) (*InstanceKey, error)

ParseRawInstanceKeyLoose 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 detahced: 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 detahced: 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

Jump to

Keyboard shortcuts

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