utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMysqlConnectionTimeout = 10000 // milliseconds
	DefaultMysqlReadTimeout       = 30000
	DefaultMysqlWriteTimeout      = 30000
)
View Source
const DefaultCheckProgressInterval = time.Second * 30

Variables

View Source
var SaramaVersion = sarama.V3_3_1_0

Functions

func AbsInt

func AbsInt(x int) int

func CloseMysqlConnection

func CloseMysqlConnection(db *sql.DB) error

CloseMysqlConnection closes mysql client connection

func ConfigToStruct

func ConfigToStruct(source core.StringMap, target interface{}) error

ConfigToStruct converts a map to corresponding struct.

func CreateMysqlConnection

func CreateMysqlConnection(host string, port uint16, user string, password string) (db1 *sql.DB, err error)

CreateMysqlConnection creates a new instance of mysql connection

func FullTableName

func FullTableName(db string, table string) string

func GenerateRandomServerID

func GenerateRandomServerID() uint32

func GenerateSqlAndArgs

func GenerateSqlAndArgs(event *core.DBChangeEvent, keyColumns []string) (sqlString string, sqlArgs []interface{})

func GetArrayFromConfig

func GetArrayFromConfig(config core.StringMap, path string) ([]interface{}, error)

func GetConfigArrayFromConfig

func GetConfigArrayFromConfig(config core.StringMap, path string) ([]core.StringMap, error)

func GetConfigFromConfig

func GetConfigFromConfig(config core.StringMap, path string) (core.StringMap, error)

func GetFNV64aHash

func GetFNV64aHash(text string) int

func GetIntFromConfig

func GetIntFromConfig(config core.StringMap, path string) (int, error)

func GetStringFromConfig

func GetStringFromConfig(config core.StringMap, path string) (string, error)

func GetTypeName

func GetTypeName(v interface{}) string

GetTypeName returns type's name as string

func IntervalCheckTicker

func IntervalCheckTicker(intervalMS int64) *time.Ticker

IntervalCheckTicker ensure things happen in intervalMS period so use a much smaller check interval than intervalMS to prevent the extreme near 2*intervalMS situation.

func IsMultipleStatements

func IsMultipleStatements(sqlString string) bool

func IsNil

func IsNil(v interface{}) bool

IsNil works around the famous issue https://stackoverflow.com/questions/13476349/check-for-nil-and-nil-interface-in-go

func LoadColumnTypes

func LoadColumnTypes(db string, table string, cols []string, conn *sql.DB) ([]*sql.ColumnType, error)

func LookupDNS

func LookupDNS(host string) ([]string, error)

func NewBatchDataPointers

func NewBatchDataPointers(columnTypes []*sql.ColumnType, size int) [][]interface{}

func ReadDataFromPointers

func ReadDataFromPointers(pointers []interface{}) []interface{}

func ScanRowsWithDataPointers

func ScanRowsWithDataPointers(rows *sql.Rows, columnTypes []*sql.ColumnType, vPtrs []interface{}) ([]interface{}, error)

func ScanType

func ScanType(columnType *sql.ColumnType) reflect.Type

func SignalQuit

func SignalQuit() chan os.Signal

Types

type DDLInfo

type DDLInfo struct {
	DB    string
	Table string
	Node  ast.StmtNode
}

func ExtractFromDDL

func ExtractFromDDL(schema []byte, stmt ast.StmtNode) []*DDLInfo

ExtractFromDDL extracts DDL information from statement.

Jump to

Keyboard shortcuts

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