mysql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 28 Imported by: 0

README

MySQL adaptor

Using the adaptor

You need to specify a sink and source like so:

var source = mysql({
  "uri": "mysql://user:pass@source.host.com:11111/database?ssl=custom",
  "tail": true,
  "cacert": "/path/to/source.crt",
})

var sink = mysql({
  "uri": "mysql://user:pass@sink.host.com:22222/database?ssl=custom",
  "cacert": "/path/to/sink.crt",
  "servername": "sink.host.com",
})

t.Source("source", source, "/.*/").Save("sink", sink, "/.*/")
  • tailing is optional and only makes sense on the source
  • For TLS you can use ssl=true which does unverified TLS or ssl=custom in which case you need to supply the cacert.
  • You don't need to supply the servername, but if you do the certificate will be verified against it
Requirements
  • The source must allow the connecting user to query the binlog
  • Per Postgresql you need to create the sink/destination table structure first
Limitations
  • Note that per the Postgresql adaptor this probably isn't very performant at copying huge databases as there is no bulk option yet.
  • Has only been developed and tested using MySQL as the sink and source. Unsure how it will function when combined with other adaptors.

Documentation

Index

Constants

View Source
const (
	// DefaultURI is the default endpoint of MySQL on the local machine.
	// Primarily used when initializing a new Client without a specific URI.
	DefaultURI = "mysql://root@localhost:3306?"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a client to the underlying File source.

func NewClient

func NewClient(options ...ClientOptionFunc) (*Client, error)

NewClient creates a default file client

func (*Client) Close

func (c *Client) Close()

Close implements necessary calls to cleanup the underlying *sql.DB

func (*Client) Connect

func (c *Client) Connect() (client.Session, error)

Connect initializes the MySQL connection

type ClientOptionFunc

type ClientOptionFunc func(*Client) error

ClientOptionFunc is a function that configures a Client. It is used in NewClient.

func WithCustomTLS

func WithCustomTLS(uri string, cert string, serverName string) ClientOptionFunc

WithCustomTLS configures the RootCAs for the underlying TLS connection

func WithURI

func WithURI(uri string) ClientOptionFunc

WithURI defines the full connection string for the MySQL connection Make this handle the different DSNs for these two? - https://github.com/go-sql-driver/mysql#dsn-data-source-name - https://github.com/go-mysql-org/go-mysql#driver

type Reader

type Reader struct {
}

Reader implements the behaviour defined by client.Reader for interfacing with MySQL.

func (*Reader) Read

func (r *Reader) Read(resumeMap map[string]client.MessageSet, filterFn client.NsFilterFunc) client.MessageChanFunc

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session serves as a wrapper for the underlying *sql.DB

type Tailer

type Tailer struct {
	// contains filtered or unexported fields
}

Tailer implements the behaviour defined by client.Tailer for interfacing with the MySQL binlog. We'll have to pass through the dsn so that we can use it to configure the sync client

func (*Tailer) Read

func (t *Tailer) Read(resumeMap map[string]client.MessageSet, filterFn client.NsFilterFunc) client.MessageChanFunc

Tail does the things

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer implements client.Writer for use with MySQL

func (*Writer) Write

func (w *Writer) Write(msg message.Msg) func(client.Session) (message.Msg, error)

Jump to

Keyboard shortcuts

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