Documentation ¶
Index ¶
- Constants
- func CheckMagic(rawSql string) (valid bool)
- func CompareRemainStr(target, magicRemainStr, magicRet string, magicRemainIndex []int) bool
- func CompareTime(target, match string, timeStart, timeEnd []int, min bool) (valid bool)
- func CompareWithStartTime(data models.Data, timestampKey string, startTime time.Time) (int, bool)
- func CompareWithStartTimeInt(data models.Data, timestampKey string, startTimeInt int64) (int, bool)
- func CompareWithStartTimeStr(data models.Data, timestampKey, startTimeStr string) (int, bool)
- func Contains(slice []string, str string) bool
- func ConvertBool(v interface{}) (bool, error)
- func ConvertDate(v interface{}) (time.Time, error)
- func ConvertFloat(v interface{}) (float64, error)
- func ConvertLong(v interface{}) (int64, error)
- func ConvertMagicIndex(magic string, now time.Time) (Ret string, index int)
- func ConvertScanArgs(data models.Data, scanArg interface{}, column, runnerName, name string, ...) (int64, error)
- func ConvertString(v interface{}) (string, error)
- func ConvertUUID(v interface{}) (string, error)
- func EqualTime(target, magicRet string, timeStart, timeEnd []int) (valid bool)
- func GetInitScans(length int, rows *sql.Rows, schemas map[string]string, runnerName, name string) (scanArgs []interface{}, nochoiced []bool)
- func GetOffsetIndex(offsetKey string, columns []string) int
- func GetOffsetIndexWithTimeStamp(offsetKey, timestampKey string, columns []string) int
- func GetRemainStr(origin string, magicRemainIndex []int) (remainStr string)
- func GetTimeFromArgs(offsetKeyIndex int, scanArgs []interface{}) (time.Time, bool)
- func GetTimeFromData(data models.Data, timestampKey string) (time.Time, bool)
- func GetTimeIntFromArgs(offsetKeyIndex int, scanArgs []interface{}) (int64, bool)
- func GetTimeIntFromData(data models.Data, timestampKey string) (int64, bool)
- func GetTimeStrFromData(data models.Data, timestampKey string) (string, bool)
- func OpenSql(dbtype, connectStr string) (db *sql.DB, err error)
- func QueryNumber(tsql string, db *sql.DB) (int64, error)
- func RemoveWildcards(checkWildcards string, length int) int
- func RestoreMeta(meta *reader.Meta, rawSqls string, magicLagDur time.Duration) (offsets []int64, sqls []string, omitMeta bool)
- func RestoreSqls(meta *reader.Meta) map[string]string
- func RestoreTimestampIntOffset(doneFilePath string) (int64, map[string]string, error)
- func RestoreTimestampOffset(doneFilePath string) (time.Time, map[string]string, error)
- func RestoreTimestampStrOffset(doneFilePath string) (string, map[string]string, error)
- func SchemaCheck(rawSchemas []string) (schemas map[string]string, err error)
- func UpdateSqls(rawsqls string, now time.Time) []string
- func WriteCacheMap(doneFilePath string, cache map[string]string) (err error)
- func WriteRecordsFile(doneFilePath, content string) (err error)
- func WriteSqlsFile(doneFilePath, content string) (err error)
- func WriteTimestampOffset(doneFilePath, content string) (err error)
- type ByJson
- type DBRecords
- func (dbRecords *DBRecords) GetTableRecords(db string) TableRecords
- func (dbRecords *DBRecords) Reset()
- func (dbRecords *DBRecords) Set(value DBRecords)
- func (dbRecords *DBRecords) SetTableInfo(db, table string, tableInfo TableInfo)
- func (dbRecords *DBRecords) SetTableRecords(db string, tableRecords TableRecords)
- type MagicRes
- type ReadInfo
- type SyncDBRecords
- func (syncDBRecords *SyncDBRecords) CheckDoneRecords(target, curDB string) bool
- func (syncDBRecords *SyncDBRecords) GetDBRecords() DBRecords
- func (syncDBRecords *SyncDBRecords) GetTableRecords(db string) TableRecords
- func (syncDBRecords *SyncDBRecords) Reset()
- func (dbRecords *SyncDBRecords) RestoreRecordsFile(meta *reader.Meta) (lastDB, lastTable string, omitDoneDBRecords bool)
- func (syncDBRecords *SyncDBRecords) SetTableInfo(db, table string, tableInfo TableInfo)
- func (syncDBRecords *SyncDBRecords) SetTableRecords(db string, tableRecords TableRecords)
- type TableInfo
- type TableRecords
- func (tableRecords *TableRecords) GetTable() map[string]TableInfo
- func (tableRecords *TableRecords) GetTableInfo(table string) TableInfo
- func (tableRecords *TableRecords) Reset()
- func (tableRecords *TableRecords) RestoreTableDone(meta *reader.Meta, database string, tables []string) bool
- func (tableRecords *TableRecords) Set(value TableRecords)
- func (tableRecords *TableRecords) SetTableInfo(table string, tableInfo TableInfo)
Constants ¶
View Source
const ( SqlOffsetConnector = "##" SqlSpliter = ";" DefaultMySQLTable = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='DATABASE_NAME';" DefaultMySQLDatabase = "SHOW DATABASES;" DefaultPGSQLTable = "SELECT TABLENAME FROM PG_TABLES WHERE SCHEMANAME='SCHEMA_NAME';" DefaultMSSQLTable = "" /* 144-byte string literal not displayed */ SupportReminder = "magic only support @(YYYY) @(YY) @(MM) @(DD) @(hh) @(mm) @(ss)" Wildcards = "*" DefaultDoneRecordsFile = "sql.records" DefaultDoneSqlsFile = "sqls" TimestampRecordsFile = "timestamp.records" CacheMapFile = "cachemap.records" )
View Source
const ( // 获取符合条件的table TABLE = iota // 获取符合条件的database DATABASE // 获取数据库表的总条数 COUNT )
View Source
const ( // 获取数据条数的函数 COUNTFUNC = iota // 获取读取数据的函数 READFUNC )
View Source
const ( YEAR = iota MONTH DAY HOUR MINUTE SECOND )
Variables ¶
This section is empty.
Functions ¶
func CheckMagic ¶
func CompareRemainStr ¶
func CompareTime ¶
查看时间是否符合, min为true则取出来为小于等于,min为false则取出来大于等于
func CompareWithStartTime ¶
-1 代表不存在; 1 代表更大; 0 代表相等
func CompareWithStartTimeInt ¶
-1 代表不存在; 1 代表更大; 0 代表相等
func CompareWithStartTimeStr ¶
-1 代表不存在; 1 代表更大; 0 代表相等
func ConvertBool ¶
func ConvertDate ¶
func ConvertFloat ¶
func ConvertLong ¶
func ConvertMagicIndex ¶
仅支持 YYYY, YY, MM, DD, hh, mm, ss,不支持 M, D, h, m, s
func ConvertScanArgs ¶
func ConvertString ¶
func ConvertUUID ¶
func GetInitScans ¶
func GetOffsetIndex ¶
func GetRemainStr ¶
func GetTimeFromArgs ¶
func GetTimeFromData ¶
func GetTimeIntFromArgs ¶
func GetTimeIntFromData ¶
func GetTimeStrFromData ¶
func RemoveWildcards ¶
若包含通配符,字段长度相应 - 1
func RestoreMeta ¶
func RestoreTimestampOffset ¶
func WriteRecordsFile ¶
WriteRecordsFile 将当前文件写入donefiel中
func WriteSqlsFile ¶
WriteSqlsFile 将当前文件写入donefiel中
func WriteTimestampOffset ¶
Types ¶
type DBRecords ¶
type DBRecords map[string]TableRecords
func (*DBRecords) GetTableRecords ¶
func (dbRecords *DBRecords) GetTableRecords(db string) TableRecords
func (*DBRecords) SetTableInfo ¶
func (*DBRecords) SetTableRecords ¶
func (dbRecords *DBRecords) SetTableRecords(db string, tableRecords TableRecords)
type MagicRes ¶
type ReadInfo ¶
func SortByJson ¶
if Marshal failed return all data
type SyncDBRecords ¶
func (*SyncDBRecords) CheckDoneRecords ¶
func (syncDBRecords *SyncDBRecords) CheckDoneRecords(target, curDB string) bool
func (*SyncDBRecords) GetDBRecords ¶
func (syncDBRecords *SyncDBRecords) GetDBRecords() DBRecords
func (*SyncDBRecords) GetTableRecords ¶
func (syncDBRecords *SyncDBRecords) GetTableRecords(db string) TableRecords
func (*SyncDBRecords) Reset ¶
func (syncDBRecords *SyncDBRecords) Reset()
func (*SyncDBRecords) RestoreRecordsFile ¶
func (dbRecords *SyncDBRecords) RestoreRecordsFile(meta *reader.Meta) (lastDB, lastTable string, omitDoneDBRecords bool)
func (*SyncDBRecords) SetTableInfo ¶
func (syncDBRecords *SyncDBRecords) SetTableInfo(db, table string, tableInfo TableInfo)
func (*SyncDBRecords) SetTableRecords ¶
func (syncDBRecords *SyncDBRecords) SetTableRecords(db string, tableRecords TableRecords)
type TableRecords ¶
func (*TableRecords) GetTable ¶
func (tableRecords *TableRecords) GetTable() map[string]TableInfo
func (*TableRecords) GetTableInfo ¶
func (tableRecords *TableRecords) GetTableInfo(table string) TableInfo
func (*TableRecords) Reset ¶
func (tableRecords *TableRecords) Reset()
func (*TableRecords) RestoreTableDone ¶
func (*TableRecords) Set ¶
func (tableRecords *TableRecords) Set(value TableRecords)
func (*TableRecords) SetTableInfo ¶
func (tableRecords *TableRecords) SetTableInfo(table string, tableInfo TableInfo)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.