mysql

package
v0.0.0-...-e2b6bb1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// DefaultWorkerCount is the default number of workers.
	DefaultWorkerCount = 16
	// DefaultMaxTxnRow is the default max number of rows in a transaction.
	DefaultMaxTxnRow = 256

	// BackoffBaseDelay indicates the base delay time for retrying.
	BackoffBaseDelay = 500 * time.Millisecond
	// BackoffMaxDelay indicates the max delay time for retrying.
	BackoffMaxDelay = 60 * time.Second
)

Variables

This section is empty.

Functions

func CheckIfBDRModeIsSupported

func CheckIfBDRModeIsSupported(ctx context.Context, db *sql.DB) (bool, error)

CheckIfBDRModeIsSupported checks if the downstream supports BDR mode.

func CheckIsTiDB

func CheckIsTiDB(ctx context.Context, db *sql.DB) (bool, error)

CheckIsTiDB checks if the downstream is TiDB.

func CreateMySQLDBConn

func CreateMySQLDBConn(ctx context.Context, dsnStr string) (*sql.DB, error)

CreateMySQLDBConn creates a mysql database connection with the given dsn.

func GenBasicDSN

func GenBasicDSN(sinkURI *url.URL, cfg *Config) (*dmysql.Config, error)

GenBasicDSN generates a basic DSN from the given config.

func GenerateDSN

func GenerateDSN(ctx context.Context, sinkURI *url.URL, cfg *Config, dbConnFactory Factory) (dsnStr string, err error)

GenerateDSN generates the dsn with the given config.

func GetTestDB

func GetTestDB(ctx context.Context, dbConfig *dmysql.Config, dbConnFactory Factory) (*sql.DB, error)

GetTestDB checks and adjusts the password of the given DSN, it will return a DB instance opened with the adjusted password.

func MockTestDB

func MockTestDB(adjustSQLMode bool) (*sql.DB, error)

MockTestDB creates a mock mysql database connection.

func QueryMaxAllowedPacket

func QueryMaxAllowedPacket(ctx context.Context, db *sql.DB) (int64, error)

QueryMaxAllowedPacket gets the value of max_allowed_packet

func QueryMaxPreparedStmtCount

func QueryMaxPreparedStmtCount(ctx context.Context, db *sql.DB) (int, error)

QueryMaxPreparedStmtCount gets the value of max_prepared_stmt_count

Types

type Config

type Config struct {
	WorkerCount            int
	MaxTxnRow              int
	MaxMultiUpdateRowCount int
	MaxMultiUpdateRowSize  int

	ReadTimeout    string
	WriteTimeout   string
	DialTimeout    string
	SafeMode       bool
	Timezone       string
	TLS            string
	ForceReplicate bool

	IsTiDB bool // IsTiDB is true if the downstream is TiDB
	// IsBDRModeSupported is true if the downstream is TiDB and write source is existed.
	// write source exists when the downstream is TiDB and version is greater than or equal to v6.5.0.
	IsWriteSourceExisted bool

	SourceID        uint64
	BatchDMLEnable  bool
	MultiStmtEnable bool
	CachePrepStmts  bool
	// contains filtered or unexported fields
}

Config is the configs for MySQL backend.

func NewConfig

func NewConfig() *Config

NewConfig returns the default mysql backend config.

func (*Config) Apply

func (c *Config) Apply(
	serverTimezone string,
	changefeedID model.ChangeFeedID,
	sinkURI *url.URL,
	replicaConfig *config.ReplicaConfig,
) (err error)

Apply applies the sink URI parameters to the config.

type Factory

type Factory func(ctx context.Context, dsnStr string) (*sql.DB, error)

Factory is the factory for creating db connection.

Jump to

Keyboard shortcuts

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