river

package
v0.0.0-...-db4d63e Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MyAddr     string `toml:"my_addr"`
	MyUser     string `toml:"my_user"`
	MyPassword string `toml:"my_pass"`
	MyCharset  string `toml:"my_charset"`
	AllDB      string `toml:"my_alldb"`

	MongoAddr     string `toml:"mongo_addr"`
	MongoUser     string `toml:"mongo_user"`
	MongoPassword string `toml:"mongo_pass"`

	StatAddr string `toml:"stat_addr"`

	ServerID uint32 `toml:"server_id"`
	Flavor   string `toml:"flavor"`
	DataDir  string `toml:"data_dir"`

	DumpExec string `toml:"mysqldump"`

	Sources []SourceConfig `toml:"source"`

	Rules []*Rule `toml:"rule"`

	BulkSize int `toml:"bulk_size"`

	FlushBulkTime TomlDuration `toml:"flush_bulk_time"`
}

func NewConfig

func NewConfig(data string) (*Config, error)

func NewConfigWithFile

func NewConfigWithFile(name string) (*Config, error)

type River

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

func NewRiver

func NewRiver(c *Config) (*River, error)

func (*River) Close

func (r *River) Close()

func (*River) Ctx

func (r *River) Ctx() context.Context

func (*River) Start

func (r *River) Start() error

type Rule

type Rule struct {
	Schema     string   `toml:"schema"`
	Table      string   `toml:"table"`
	Database   string   `toml:"database"`
	Collection string   `toml:"collection"`
	ID         []string `toml:"id"`

	// Default, a MySQL table field name is mapped to MongoDB field name.
	// Sometimes, you want to use different name, e.g, the MySQL file name is title,
	// but in Elasticsearch, you want to name it my_title.
	FieldMapping map[string]string `toml:"field"`

	// MySQL table information
	TableInfo *schema.Table

	//only MySQL fields in fileter will be synced , default sync all fields
	Fileter []string `toml:"filter"`
}

If you want to sync MySQL data into MongoDB, you must set a rule to let use know how to do it. The mapping rule may thi: schema + table <-> database + collection. schema and table is for MySQL, database and collection type is for MongoDB.

func (*Rule) CheckFilter

func (r *Rule) CheckFilter(field string) bool

type SourceConfig

type SourceConfig struct {
	Schema string   `toml:"schema"`
	Tables []string `toml:"tables"`
}

type TomlDuration

type TomlDuration struct {
	time.Duration
}

func (*TomlDuration) UnmarshalText

func (d *TomlDuration) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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