schema

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: GPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MemDbHost = "localhost"
View Source
var MemDbPort = 5166 // default 5166

Functions

func FindMetaFileNotCreate

func FindMetaFileNotCreate(filePath string, initData string)

func GetMetaFilePath

func GetMetaFilePath(conf *config.BaseConfig) string

Types

type ColumnType

type ColumnType = int
const (
	TypeNumber    ColumnType = iota + 1 // tinyint, smallint, int, bigint, year
	TypeMediumInt                       // medium int
	TypeFloat                           // float, double
	TypeEnum                            // enum
	TypeSet                             // set
	TypeString                          // other
	TypeDatetime                        // datetime
	TypeTimestamp                       // timestamp
	TypeDate                            // date
	TypeTime                            // time
	TypeBit                             // bit
	TypeJson                            // json
	TypeDecimal                         // decimal
)

type MongoTables

type MongoTables struct {
	*config.MongoConfig
	// contains filtered or unexported fields
}

func (*MongoTables) AddTable

func (mts *MongoTables) AddTable(db string, table string) (*Table, error)

func (*MongoTables) AddTableForMsg

func (mts *MongoTables) AddTableForMsg(msg *msg.Msg) error

func (*MongoTables) Close

func (mts *MongoTables) Close()

func (*MongoTables) DelTable added in v0.4.1

func (mts *MongoTables) DelTable(db string, table string) error

func (*MongoTables) GetTable

func (mts *MongoTables) GetTable(db string, table string) (*Table, error)

func (*MongoTables) NewSchemaTables

func (mts *MongoTables) NewSchemaTables(conf *config.BaseConfig, pluginConfig interface{}, startPos string, rulesMap map[string]interface{})

func (*MongoTables) RefreshTable

func (mts *MongoTables) RefreshTable(db string, table string)

func (*MongoTables) SaveMeta added in v0.3.3

func (mts *MongoTables) SaveMeta(data string) error

func (*MongoTables) UpdateTable

func (mts *MongoTables) UpdateTable(db string, table string, args interface{}, pos string) (err error)

type MysqlTables

type MysqlTables struct {
	sync.RWMutex
	*config.MysqlConfig

	*MysqlTablesMeta

	FilePath string
	// contains filtered or unexported fields
}

func (*MysqlTables) AddCreateTable added in v0.3.3

func (mts *MysqlTables) AddCreateTable(db string, table string, cols interface{}) error

func (*MysqlTables) AddTable

func (mts *MysqlTables) AddTable(db string, table string) (*Table, error)

func (*MysqlTables) AddTableForMsg

func (mts *MysqlTables) AddTableForMsg(msg *msg.Msg) error

func (*MysqlTables) ClearTableCache

func (mts *MysqlTables) ClearTableCache(db []byte, table []byte)

ClearTableCache clear table cache

func (*MysqlTables) Close

func (mts *MysqlTables) Close()

func (*MysqlTables) DelTable added in v0.4.1

func (mts *MysqlTables) DelTable(db string, table string) error

func (*MysqlTables) ExecuteSQL

func (mts *MysqlTables) ExecuteSQL(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTables) GetColumnTypeFromRawType

func (mts *MysqlTables) GetColumnTypeFromRawType(rawType string) int

func (*MysqlTables) GetTable

func (mts *MysqlTables) GetTable(db string, table string) (*Table, error)

func (*MysqlTables) LoadMetaFromDB

func (mts *MysqlTables) LoadMetaFromDB()

func (*MysqlTables) LoadMetaFromLocal

func (mts *MysqlTables) LoadMetaFromLocal(conf *config.BaseConfig)

func (*MysqlTables) NewSchemaTables

func (mts *MysqlTables) NewSchemaTables(conf *config.BaseConfig, pluginConfig interface{}, startPos string, rulesMap map[string]interface{})

func (*MysqlTables) RefreshTable

func (mts *MysqlTables) RefreshTable(db string, table string)

func (*MysqlTables) SaveMeta

func (mts *MysqlTables) SaveMeta(data string) error

func (*MysqlTables) UpdateTable

func (mts *MysqlTables) UpdateTable(db string, table string, spec interface{}, pos string) (err error)

type MysqlTablesMeta

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

type MysqlTablesMetaV2 added in v0.3.4

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

type MysqlTablesMetaV3 added in v0.4.1

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

type MysqlTablesV2 added in v0.3.4

type MysqlTablesV2 struct {
	sync.RWMutex
	*config.MysqlConfig

	*MysqlTablesMetaV2

	FilePath string
	// contains filtered or unexported fields
}

func (*MysqlTablesV2) AddTable added in v0.3.4

func (mts *MysqlTablesV2) AddTable(db string, table string) (*Table, error)

func (*MysqlTablesV2) AddTableForMsg added in v0.3.4

func (mts *MysqlTablesV2) AddTableForMsg(msg *msg.Msg) error

func (*MysqlTablesV2) Close added in v0.3.4

func (mts *MysqlTablesV2) Close()

func (*MysqlTablesV2) DelTable added in v0.4.1

func (mts *MysqlTablesV2) DelTable(db string, table string) error

func (*MysqlTablesV2) ExecuteSQL added in v0.3.4

func (mts *MysqlTablesV2) ExecuteSQL(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTablesV2) ExecuteSQLForMemDB added in v0.3.4

func (mts *MysqlTablesV2) ExecuteSQLForMemDB(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTablesV2) GetColumnTypeFromRawType added in v0.3.4

func (mts *MysqlTablesV2) GetColumnTypeFromRawType(rawType string) int

func (*MysqlTablesV2) GetTable added in v0.3.4

func (mts *MysqlTablesV2) GetTable(db string, table string) (*Table, error)

func (*MysqlTablesV2) GetTableCreateDDL added in v0.3.4

func (mts *MysqlTablesV2) GetTableCreateDDL(db string, table string) (string, error)

func (*MysqlTablesV2) LoadMetaFromDB added in v0.3.4

func (mts *MysqlTablesV2) LoadMetaFromDB() map[string]interface{}

func (*MysqlTablesV2) NewSchemaTables added in v0.3.4

func (mts *MysqlTablesV2) NewSchemaTables(conf *config.BaseConfig, pluginConfig interface{}, startPos string, rulesMap map[string]interface{})

func (*MysqlTablesV2) RefreshTable added in v0.3.4

func (mts *MysqlTablesV2) RefreshTable(db string, table string)

func (*MysqlTablesV2) SaveMeta added in v0.3.4

func (mts *MysqlTablesV2) SaveMeta(tablesMeta string) error

func (*MysqlTablesV2) StartTimerSaveMeta added in v0.3.4

func (mts *MysqlTablesV2) StartTimerSaveMeta([]*regexp.Regexp)

func (*MysqlTablesV2) UpdateTable added in v0.3.4

func (mts *MysqlTablesV2) UpdateTable(db string, table string, ddl interface{}, pos string) (err error)

type MysqlTablesV3 added in v0.4.1

type MysqlTablesV3 struct {
	sync.RWMutex
	*config.MysqlConfig

	*MysqlTablesMetaV3

	FilePath string
	// contains filtered or unexported fields
}

func (*MysqlTablesV3) AddTable added in v0.4.1

func (mts *MysqlTablesV3) AddTable(db string, table string) (*Table, error)

func (*MysqlTablesV3) AddTableForMsg added in v0.4.1

func (mts *MysqlTablesV3) AddTableForMsg(msg *msg.Msg) error

func (*MysqlTablesV3) Close added in v0.4.1

func (mts *MysqlTablesV3) Close()

func (*MysqlTablesV3) DelTable added in v0.4.1

func (mts *MysqlTablesV3) DelTable(db string, table string) (err error)

func (*MysqlTablesV3) ExecuteSQL added in v0.4.1

func (mts *MysqlTablesV3) ExecuteSQL(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTablesV3) ExecuteSQLForMemDB added in v0.4.1

func (mts *MysqlTablesV3) ExecuteSQLForMemDB(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTablesV3) GetColumnTypeFromRawType added in v0.4.1

func (mts *MysqlTablesV3) GetColumnTypeFromRawType(rawType string) int

func (*MysqlTablesV3) GetTable added in v0.4.1

func (mts *MysqlTablesV3) GetTable(db string, table string) (*Table, error)

func (*MysqlTablesV3) GetTableCreateDDL added in v0.4.1

func (mts *MysqlTablesV3) GetTableCreateDDL(db string, table string) (string, error)

func (*MysqlTablesV3) LoadMetaFromDB added in v0.4.1

func (mts *MysqlTablesV3) LoadMetaFromDB(rulesMap map[string]interface{}) map[string]interface{}

func (*MysqlTablesV3) LoadSyncTableMetaFromDB added in v0.4.1

func (mts *MysqlTablesV3) LoadSyncTableMetaFromDB() map[string]interface{}

func (*MysqlTablesV3) NewSchemaTables added in v0.4.1

func (mts *MysqlTablesV3) NewSchemaTables(conf *config.BaseConfig, pluginConfig interface{}, startPos string, rulesMap map[string]interface{})

func (*MysqlTablesV3) RefreshTable added in v0.4.1

func (mts *MysqlTablesV3) RefreshTable(db string, table string)

func (*MysqlTablesV3) SaveMeta added in v0.4.1

func (mts *MysqlTablesV3) SaveMeta(tablesMeta string) error

func (*MysqlTablesV3) StartTimerSaveMeta added in v0.4.1

func (mts *MysqlTablesV3) StartTimerSaveMeta()

func (*MysqlTablesV3) UpdateTable added in v0.4.1

func (mts *MysqlTablesV3) UpdateTable(db string, table string, ddl interface{}, pos string) (err error)

type Schema

type Schema interface {
	NewSchemaTables(config *config.BaseConfig, pluginConfig interface{}, startPos string, rulesMap map[string]interface{})
	AddTableForMsg(msg *msg.Msg) error
	AddTable(db string, table string) (*Table, error)
	DelTable(db string, table string) error
	UpdateTable(db string, table string, args interface{}, pos string) error
	GetTable(db string, table string) (*Table, error)
	RefreshTable(db string, table string)
	SaveMeta(data string) error
	Close()
}

type Table

type Table struct {
	Schema  string        `toml:"schema" json:"schema"`
	Name    string        `toml:"name" json:"name"`
	Columns []TableColumn `toml:"columns" json:"columns"`
}

func (*Table) DelColumn added in v0.3.3

func (t *Table) DelColumn(name string) error

func (*Table) FindColumn

func (t *Table) FindColumn(name string) int

func (*Table) GetTableColumnsName

func (t *Table) GetTableColumnsName() []string

type TableColumn

type TableColumn struct {
	Name    string     `toml:"name" json:"name"`
	Type    ColumnType `toml:"type" json:"type"`
	RawType string     `toml:"raw_type" json:"raw_type"`
}

Jump to

Keyboard shortcuts

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