Documentation ¶
Index ¶
- Constants
- Variables
- func AddSuffixForUUID(uuid string, id int) string
- func AdjustBinaryProtocolForDatum(ctx sessionctx.Context, data []interface{}, cols []*model.ColumnInfo) ([]types.Datum, error)
- func CollectDirFiles(path string) (map[string]struct{}, error)
- func CompareShardingDDLs(s, t []string) bool
- func ConstructFilename(baseName, seq string) string
- func ConstructFilenameWithUUIDSuffix(originalName Filename, uuidSuffix string) string
- func DecodeBinlogPosition(pos string) (*mysql.Position, error)
- func Decrypt(ciphertextB64 string) (string, error)
- func DecryptOrPlaintext(ciphertextB64 string) string
- func Encrypt(plaintext string) (string, error)
- func EncryptOrPlaintext(plaintext string) string
- func ExtractDBAndTableFromLockID(lockID string) (string, string)
- func ExtractRealName(name string) string
- func ExtractTaskFromLockID(lockID string) string
- func GenDDLLockID(task, schema, table string) string
- func GenFakeRotateEvent(nextLogName string, logPos uint64, serverID uint32) (*replication.BinlogEvent, error)
- func GenHashKey(key string) uint32
- func GenSchemaID(table *filter.Table) string
- func GenTableID(table *filter.Table) string
- func GenTableIDAndCheckSchemaOnly(table *filter.Table) (id string, isSchemaOnly bool)
- func GetDBFromDumpFilename(filename string) (db string, ok bool)
- func GetFileSize(file string) (int64, error)
- func GetFilenameIndex(filename string) (int64, error)
- func GetTableFromDumpFilename(filename string) (db, table string, ok bool)
- func GetUUIDBySuffix(uuids []string, suffix string) string
- func GoLogWrapper(logger log.Logger, fn func())
- func IgnoreErrorCheckpoint(err error) bool
- func IsBuildInSkipDDL(sql string) bool
- func IsContextCanceledError(err error) bool
- func IsDirExists(name string) bool
- func IsFakeRotateEvent(header *replication.EventHeader) bool
- func IsFileExists(name string) bool
- func LogHTTPProxies(useLogger bool)
- func NewSessionCtx(vars map[string]string) sessionctx.Context
- func NewStoppedTimer() *time.Timer
- func NonRepeatStringsEqual(a, b []string) bool
- func ParseFileSize(fileSizeStr string, defaultSize uint64) (uint64, error)
- func ParseRelaySubDir(uuid string) (string, int, error)
- func ParseStartTime(timeStr string) (time.Time, error)
- func ParseStartTimeInLoc(timeStr string, loc *time.Location) (time.Time, error)
- func ParseTimeZone(s string) (*time.Location, error)
- func ParseUUIDIndex(indexPath string) ([]string, error)
- func SetToSlice(set map[string]struct{}) []string
- func SplitFilenameWithUUIDSuffix(filename string) (baseName, uuidSuffix, seq string, err error)
- func SuffixIntToStr(id int) string
- func TrimCtrlChars(s string) string
- func TrimQuoteMark(s string) string
- func TruncateInterface(v interface{}, n int) string
- func TruncateString(s string, n int) string
- func TruncateStringQuiet(s string, n int) string
- func UnpackTableID(id string) *filter.Table
- func UnwrapScheme(s string) string
- func VerifyFilename(filename string) bool
- func WaitSomething(backoff int, waitTime time.Duration, fn func() bool) bool
- func WrapSchemes(s string, https bool) string
- func WrapSchemesForInitialCluster(s string, https bool) string
- func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
- type Filename
- type StorageSize
Constants ¶
const ( StartTimeFormat = "2006-01-02 15:04:05" StartTimeFormat2 = "2006-01-02T15:04:05" )
const ( // PosRelaySubDirSuffixSeparator is used to differ binlog position from multiple // (switched) masters, we added a suffix which comes from relay log subdirectory // into binlogPos.Name. And we also need support position with RelaySubDirSuffix // should always > position without RelaySubDirSuffix, so we can continue from // latter to former automatically. convertedPos.BinlogName = // originalPos.BinlogBaseName + PosRelaySubDirSuffixSeparator + RelaySubDirSuffix + binlogFilenameSep + originalPos.BinlogSeq // eg. mysql-bin.000003 under folder c6ae5afe-c7a3-11e8-a19d-0242ac130006.000002 => mysql-bin|000002.000003 // when new relay log subdirectory is created, RelaySubDirSuffix should increase. PosRelaySubDirSuffixSeparator = "|" )
Variables ¶
var ( UUIDIndexFilename = "server-uuid.index" MetaFilename = "relay.meta" )
not support to config yet.
var ( // OsExit is function placeholder for os.Exit. OsExit func(int) )
var ZeroSessionCtx sessionctx.Context
ZeroSessionCtx is used when the session variables is not important.
Functions ¶
func AddSuffixForUUID ¶
AddSuffixForUUID adds a suffix for UUID, returns the name for relay log subdirectory.
func AdjustBinaryProtocolForDatum ¶
func AdjustBinaryProtocolForDatum(ctx sessionctx.Context, data []interface{}, cols []*model.ColumnInfo) ([]types.Datum, error)
AdjustBinaryProtocolForDatum converts the data in binlog to TiDB datum.
func CollectDirFiles ¶
CollectDirFiles gets files in path.
func CompareShardingDDLs ¶
CompareShardingDDLs compares s and t ddls only concern in content, ignore order of ddl.
func ConstructFilename ¶
ConstructFilename constructs a binlog filename from the basename and seq.
func ConstructFilenameWithUUIDSuffix ¶
ConstructFilenameWithUUIDSuffix constructs a binlog filename with UUID suffix.
func DecodeBinlogPosition ¶
DecodeBinlogPosition parses a mysql.Position from string format.
func DecryptOrPlaintext ¶
DecryptOrPlaintext tries to decrypt base64 encoded ciphertext to plaintext or return plaintext. when a customized key is provided, we support both plaintext and ciphertext as password, if not provided, only plaintext is supported.
func EncryptOrPlaintext ¶
EncryptOrPlaintext tries to encrypt plaintext to base64 encoded ciphertext or return plaintext. dm-master might not set customized key, so we should handle the error and return plaintext directly.
func ExtractDBAndTableFromLockID ¶
ExtractDBAndTableFromLockID extract schema and table from lockID.
func ExtractRealName ¶
ExtractRealName removes relay log uuid suffix if it exists and returns real binlog name.
func ExtractTaskFromLockID ¶
ExtractTaskFromLockID extract task from lockID.
func GenDDLLockID ¶
GenDDLLockID returns lock ID used in shard-DDL.
func GenFakeRotateEvent ¶
func GenFakeRotateEvent(nextLogName string, logPos uint64, serverID uint32) (*replication.BinlogEvent, error)
GenFakeRotateEvent generates a fake ROTATE_EVENT without checksum ref: https://github.com/mysql/mysql-server/blob/4f1d7cf5fcb11a3f84cff27e37100d7295e7d5ca/sql/rpl_binlog_sender.cc#L855
func GenTableIDAndCheckSchemaOnly ¶
GenTableIDAndCheckSchemaOnly generates table ID and check if schema only.
func GetDBFromDumpFilename ¶
GetDBFromDumpFilename extracts db name from dump filename.
func GetFileSize ¶
GetFileSize return the size of the file. NOTE: do not support to get the size of the directory now.
func GetFilenameIndex ¶
GetFilenameIndex returns a int64 index value (seq number) of the filename.
func GetTableFromDumpFilename ¶
GetTableFromDumpFilename extracts db and table name from dump filename.
func GetUUIDBySuffix ¶
GetUUIDBySuffix gets relay log subdirectory name by matching suffix.
func GoLogWrapper ¶
GoLogWrapper go routine wrapper, log error on panic.
func IgnoreErrorCheckpoint ¶
IgnoreErrorCheckpoint is used in checkpoint update.
func IsBuildInSkipDDL ¶
IsBuildInSkipDDL return true when checked sql that will be skipped for syncer.
func IsContextCanceledError ¶
IsContextCanceledError checks whether err is context.Canceled.
func IsFakeRotateEvent ¶
func IsFakeRotateEvent(header *replication.EventHeader) bool
IsFakeRotateEvent return true if is this event is a fake rotate event If log pos equals zero then the received event is a fake rotate event and contains only a name of the next binlog file See https://github.com/mysql/mysql-server/blob/8e797a5d6eb3a87f16498edcb7261a75897babae/sql/rpl_binlog_sender.h#L235 and https://github.com/mysql/mysql-server/blob/8cc757da3d87bf4a1f07dcfb2d3c96fed3806870/sql/rpl_binlog_sender.cc#L899
func LogHTTPProxies ¶
func LogHTTPProxies(useLogger bool)
LogHTTPProxies logs HTTP proxy relative environment variables.
func NewSessionCtx ¶
func NewSessionCtx(vars map[string]string) sessionctx.Context
NewSessionCtx return a session context with specified session variables.
func NewStoppedTimer ¶
func NonRepeatStringsEqual ¶
NonRepeatStringsEqual is used to compare two un-ordered, non-repeat-element string slice is equal.
func ParseFileSize ¶
ParseFileSize parses the size in MiB from input.
func ParseRelaySubDir ¶
ParseRelaySubDir parses relay log subdirectory name to (server UUID, RelaySubDirSuffix) pair.
func ParseStartTime ¶
ParseStartTime parses start-time of task-start and validation-start in local location.
func ParseStartTimeInLoc ¶
ParseStartTimeInLoc parses start-time of task-start and validation-start.
func ParseTimeZone ¶
ParseTimeZone parse the time zone location by name or offset
NOTE: we don't support the "SYSTEM" or "Local" time_zone.
func ParseUUIDIndex ¶
ParseUUIDIndex parses UUIDIndexFilename, return a list of relay log subdirectory names and error.
func SetToSlice ¶
SetToSlice converts a map of struct{} value to a slice to pretty print.
func SplitFilenameWithUUIDSuffix ¶
SplitFilenameWithUUIDSuffix analyzes a binlog filename with UUID suffix.
func SuffixIntToStr ¶
SuffixIntToStr convert int-represented suffix to string-represented. TODO: assign RelaySubDirSuffix a type and implement Stringer.
func TrimCtrlChars ¶
TrimCtrlChars returns a slice of the string s with all leading and trailing control characters removed.
func TrimQuoteMark ¶
TrimQuoteMark tries to trim leading and tailing quote(") mark if exists only trim if leading and tailing quote matched as a pair.
func TruncateInterface ¶
TruncateInterface converts the interface to a string and returns a string with only the leading (at most) n runes of the input string. If the converted string is truncated, a `...` tail will be appended. It is not effective for large structure now.
func TruncateString ¶
TruncateString returns a string with only the leading (at most) n runes of the input string. If the string is truncated, a `...` tail will be appended.
func TruncateStringQuiet ¶
TruncateStringQuiet returns a string with only the leading (at most) n runes of the input string.
func UnpackTableID ¶
UnpackTableID unpacks table ID to <schema, table> pair.
func UnwrapScheme ¶
UnwrapScheme removes http or https scheme from input.
func VerifyFilename ¶
VerifyFilename verifies whether is a valid MySQL/MariaDB binlog filename. valid format is `base + '.' + seq`.
func WaitSomething ¶
WaitSomething waits for something done with `true`.
func WrapSchemes ¶
WrapSchemes adds http or https scheme to input if missing. input could be a comma-separated list.
func WrapSchemesForInitialCluster ¶
WrapSchemesForInitialCluster acts like WrapSchemes, except input is "name=URL,...".
Types ¶
type Filename ¶
Filename represents a binlog filename.
func ParseFilename ¶
ParseFilename parses a string representation binlog filename into a `Filename`.
func (Filename) GreaterThan ¶
GreaterThan checks whether this filename > other filename.
func (Filename) GreaterThanOrEqualTo ¶
GreaterThanOrEqualTo checks whether this filename >= other filename.
type StorageSize ¶
StorageSize represents the storage's capacity and available size Learn from tidb-binlog source code.
func GetStorageSize ¶
func GetStorageSize(dir string) (size StorageSize, err error)
GetStorageSize gets storage's capacity and available size.