Documentation
¶
Index ¶
- Constants
- type Config
- type Message
- func (m *Message) ConvertToSQL(ignoreDDL bool, useReplace bool) ([]map[string][]interface{}, error)
- func (m *Message) GetColumnNames() []string
- func (m *Message) GetColumns() map[string]string
- func (m *Message) GetDBName() string
- func (m *Message) GetData() []map[string]interface{}
- func (m *Message) GetIsDDL() bool
- func (m *Message) GetOld() []map[string]interface{}
- func (m *Message) GetPKNames() []string
- func (m *Message) GetSQLType() string
- func (m *Message) GetTableName() string
- func (m *Message) Split() []*Message
- func (m *Message) UnmarshalJSON(data []byte) error
- type PoolConfig
Constants ¶
const ( DefaultUnlimitedWaitTime = -1 // seconds DefaultUnlimitedRetryCount = -1 )
const ( SQLTypeInsert = "INSERT" SQLTypeUpdate = "UPDATE" SQLTypeDelete = "DELETE" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string
User string
Pass string
Vhost string
Tag string
Exchange string
Queue string
Key string
}
func NewConfigWithDefault ¶
NewConfigWithDefault returns a new *Config with default values
type Message ¶
type Message struct {
ID int `json:"id,omitempty"`
SQLType string `json:"type"`
IsDDL bool `json:"isDdl"`
DBName string `json:"database"`
TableName string `json:"table"`
PKNames []string `json:"pkNames"`
Columns map[string]string `json:"mysqlType"`
Data []map[string]interface{} `json:"data"`
Old []map[string]interface{} `json:"old"`
}
func NewMessage ¶
func NewMessage(id int, sqlType string, isDDL bool, dbName string, tableName string, pkNames []string, columns map[string]string, data, old []map[string]interface{}) *Message
NewMessage returns a new *Message
func (*Message) ConvertToSQL ¶
ConvertToSQL returns a map of the sql statement and the values if ignoreDDL is true, and sql type is ddl, it will only return nil, nil, if ignoreDDL is false, and sql type is ddl, it will return nil, error if useReplace is true, message with insert or update type will be converted to statements like "replace into ... values ..." if useReplace is false, message with insert type will be converted to statements like "insert into ... values ... on duplicate key update ..." if useReplace is false, message with update type will be converted to statements like "update ... set ... where ..."
func (*Message) GetColumnNames ¶
GetColumnNames gets the column names
func (*Message) GetColumns ¶
GetColumns returns the Columns
func (*Message) GetTableName ¶
GetTableName returns the TableName
func (*Message) Split ¶ added in v0.3.17
Split splits the message if the message contains multiple data
func (*Message) UnmarshalJSON ¶ added in v0.3.20
UnmarshalJSON implements the Unmarshaler interface
type PoolConfig ¶ added in v0.3.19
type PoolConfig struct {
*Config
MaxConnections int
InitConnections int
MaxIdleConnections int
MaxIdleTime int
MaxWaitTime int
MaxRetryCount int
KeepAliveInterval int
}
func NewPoolConfig ¶ added in v0.3.19
func NewPoolConfig(addr, user, host, vhost, tag, exchange, queue, key string, maxConnections, initConnections, maxIdleConnections, maxIdleTime, maxWaitTime, maxRetryCount, keepAliveInterval int) *PoolConfig
NewPoolConfig returns a new PoolConfig
func NewPoolConfigWithConfig ¶ added in v0.3.19
func NewPoolConfigWithConfig(config *Config, maxConnections, initConnections, maxIdleConnections, maxIdleTime, maxWaitTime, maxRetryCount, keepAliveInterval int) *PoolConfig
NewPoolConfigWithConfig returns a new PoolConfig
func (*PoolConfig) Clone ¶ added in v0.3.19
func (pc *PoolConfig) Clone() *PoolConfig
Clone returns a new PoolConfig with same values
func (*PoolConfig) Validate ¶ added in v0.3.19
func (pc *PoolConfig) Validate() error
Validate validates pool config