mycanal

package
v0.0.0-...-d6dd603 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package mycanal is a CDC (Change Data Capture) library for MySQL8+. No need to maintain table schemas manually any more.

It provides helper functions for full dump (package fulldump) and incremental change capture (package incrdump). Prerequisites:

  • MySQL-8.0.2 and above
  • GTID mode enabled:
  • `--gtid-mode=ON`
  • `--enforce-gtid-consistency=ON`
  • binlog enabled with the following:
  • `--log-bin=xxxx`: enable bin log
  • `--server-id=xxx`: the server id
  • `--binlog-format=ROW`: binlog output row changes instead of statments
  • `--binlog-row-image=FULL`: before and after image of row changes
  • `--binlog-row-metadata=FULL`: extra optional meta for tables such as signedness for numeric columns/column names ...

ref:

Compatiable between fulldump/incrdump (see tst/compatiable_test.go):

  • DECIMAL/NUMERIC fields are returned as string, but may have different trailing zeros.

  • BINARY fields are returned as string, but may have different trailing '\x00'.

  • JSON fields are returned as string, but elements inside may have different position.

  • TIME with fraction seems have some bugs in incrdump too.

  • GEOMETRY fields are not tested

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host of MySQL server.
	Host string `json:"host"`

	// Port of MySQL server.
	Port uint16 `json:"port"`

	// User for connection.
	User string `json:"user"`

	// Password for connection.
	Password string `json:"password"`

	// Charset for connecting.
	Charset string `json:"charset"`

	// ServerId is used by incrdump only (as a replication node).
	ServerId uint32 `json:"serverId"`
}

Config is used for fulldump and incrdump.

func (*Config) Client

func (cfg *Config) Client() (*sql.DB, error)

Client opens mysql db.

func (*Config) ToBinlogSyncerCfg

func (cfg *Config) ToBinlogSyncerCfg() replication.BinlogSyncerConfig

ToBinlogSyncerCfg converts cfg to binlog syncer config. Needs ServerId.

func (*Config) ToDriverCfg

func (cfg *Config) ToDriverCfg() *mysql.Config

ToDriverCfg converts cfg to mysql driver config.

Directories

Path Synopsis
Package fulldump provides helper functions for full dump.
Package fulldump provides helper functions for full dump.
Package incrdum provides helper functions for incremental change capture.
Package incrdum provides helper functions for incremental change capture.

Jump to

Keyboard shortcuts

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