rule

package
v0.0.0-...-1609ee8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSyncDescSchema = errors.New("invalid sync desc schema")
	ErrInvalidSyncDescTable  = errors.New("invalid sync desc table")
)

SyncDesc errors

View Source
var (
	ErrRuleConflict = errors.New("Rule conflicts")
)

Sync errors

Functions

This section is empty.

Types

type DefaultSyncConfig

type DefaultSyncConfig struct {
	Databases map[string]*defaultDatabaseConfig `json:"databases"`
}

DefaultSyncConfig is a default sync config

func NewDefaultSyncConfig

func NewDefaultSyncConfig() *DefaultSyncConfig

NewDefaultSyncConfig creates a new DefaultSyncConfig

func (*DefaultSyncConfig) ParseJSON

func (c *DefaultSyncConfig) ParseJSON(data []byte) ([]*SyncDesc, error)

ParseJSON parses the json data to SyncDesc slice to create DefaultSyncRule

func (*DefaultSyncConfig) ToSyncDescs

func (c *DefaultSyncConfig) ToSyncDescs() ([]*SyncDesc, error)

ToSyncDescs convert self to SyncDesc slice

type DefaultSyncRule

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

DefaultSyncRule implements the rule of sync

func NewDefaultSyncRule

func NewDefaultSyncRule() *DefaultSyncRule

NewDefaultSyncRule creates a new NewDefaultSyncRule

func NewDefaultSyncRuleFromJSON

func NewDefaultSyncRuleFromJSON(data []byte) (*DefaultSyncRule, error)

NewDefaultSyncRuleFromJSON creates a new DefaultSyncRule from json data

func NewDefaultSyncRuleWithRules

func NewDefaultSyncRuleWithRules(rs []*SyncDesc) (*DefaultSyncRule, error)

NewDefaultSyncRuleWithRules creates a new DefaultSyncRule with rules

func (*DefaultSyncRule) CanSyncTable

func (r *DefaultSyncRule) CanSyncTable(schema, table string) *SyncDesc

CanSyncTable implements ISyncRule CanSyncTable

func (*DefaultSyncRule) NewRule

func (r *DefaultSyncRule) NewRule(desc *SyncDesc) error

NewRule implements ISyncRule NewRule

type ISyncRule

type ISyncRule interface {
	// schema and table, returns rewrite schema and table name
	CanSyncTable(string, string) *SyncDesc
	// insert new schema rule
	NewRule(*SyncDesc) error
}

ISyncRule defines a rule which database and table can be synchronized Sync rule must be thread safe, it will be used in binlog parse thread and user worker threads. So NewRule must not be invoked once the worker is running

type SyncDesc

type SyncDesc struct {
	Schema        string
	Table         string
	RewriteSchema string
	RewriteTable  string
	IndexKeys     []string
}

SyncDesc describe a sync rule

func (*SyncDesc) Validate

func (d *SyncDesc) Validate() error

Validate check if the sync desc is valid

Jump to

Keyboard shortcuts

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