service

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright © 2020 Marvin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   = "None"
	BuildTS   = "None"
	GitHash   = "None"
	GitBranch = "None"
)

版本信息

View Source
var (
	// Oracle/Mysql 对于 'NULL' 统一字符 NULL 处理,查询出来转成 NULL,所以需要判断处理
	// 查询字段值 NULL
	// 如果字段值 = NULLABLE 则表示值是 NULL
	// 如果字段值 = "" 则表示值是空字符串
	// 如果字段值 = 'NULL' 则表示值是 NULL 字符串
	// 如果字段值 = 'null' 则表示值是 null 字符串
	IsNull = "NULLABLE"
)
View Source
var Logger *zap.Logger

Functions

func GetAppVersion

func GetAppVersion(version bool)

func NewZapLogger

func NewZapLogger(cfg *CfgFile) (err error)

初始化日志 logger

func Query

func Query(db *sql.DB, querySQL string) ([]string, []map[string]string, error)

查询返回表字段列和对应的字段行数据

func RecordAppVersion

func RecordAppVersion(app string, logger *zap.Logger, cfg *CfgFile)

版本信息输出重定向到日志

Types

type AllConfig

type AllConfig struct {
	LogminerQueryTimeout int `toml:"logminer-query-timeout" json:"logminer-query-timeout"`
	FilterThreads        int `toml:"filter-threads" json:"filter-threads"`
	ApplyThreads         int `toml:"apply-threads" json:"apply-threads"`
	WorkerQueue          int `toml:"worker-queue" json:"worker-queue"`
	WorkerThreads        int `toml:"worker-threads" json:"worker-threads"`
}

type AppConfig

type AppConfig struct {
	InsertBatchSize  int    `toml:"insert-batch-size" json:"insert-batch-size"`
	SlowlogThreshold int    `toml:"slowlog-threshold" json:"slowlog-threshold"`
	Threads          int    `toml:"threads" json:"threads"`
	PprofPort        string `toml:"pprof-port" json:"pprof-port"`
}

type CfgFile

type CfgFile struct {
	AppConfig    AppConfig    `toml:"app" json:"app"`
	FullConfig   FullConfig   `toml:"full" json:"full"`
	AllConfig    AllConfig    `toml:"all" json:"all"`
	SourceConfig SourceConfig `toml:"source" json:"source"`
	TargetConfig TargetConfig `toml:"target" json:"target"`
	LogConfig    LogConfig    `toml:"log" json:"log"`
}

程序配置文件

func ReadConfigFile

func ReadConfigFile(file string) (*CfgFile, error)

读取配置文件

func (*CfgFile) GenerateTables

func (c *CfgFile) GenerateTables(engine *Engine) ([]string, error)

根据配置文件获取表列表

func (*CfgFile) String

func (c *CfgFile) String() string

type ColumnRuleMap added in v1.0.4

type ColumnRuleMap struct {
	ID               uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	SourceSchemaName string     `gorm:"not null;index:unique_schema_col,unique;comment:'源端库 schema'" json:"source_schema_name"`
	SourceTableName  string     `gorm:"not null;index:unique_schema_col,unique;comment:'源端表名'" json:"source_table_name"`
	SourceColumnName string     `gorm:"not null;index:unique_schema_col,unique;comment:'源端表字段列名'" json:"source_column_name"`
	SourceColumnType string     `gorm:"not null;index:idx_source_col;comment:'源端表字段类型'" json:"source_column_type"`
	TargetColumnType string     `gorm:"not null;index:idx_source_col;comment:'目标表字段类型'" json:"target_column_type"`
	CreatedAt        *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt        *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}
上下游字段类型映射表

数据类型转换优先级: column > table > schema > build-in 自定义列转换规则 - 字段列级别

func (*ColumnRuleMap) AdjustColumnDataType added in v1.0.4

func (c *ColumnRuleMap) AdjustColumnDataType(tableName, columnName string) string

type DefaultValueMap added in v1.0.4

type DefaultValueMap struct {
	ID                 uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	SourceDefaultValue string     `gorm:"not null;index:unique_source_default,unique;comment:'源端默认值'" json:"source_default_value"`
	TargetDefaultValue string     `gorm:"not null;index:idx_target_default;comment:'目标默认值'" json:"target_default_value"`
	CreatedAt          *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt          *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}

自定义字段默认值转换规则 - global 级别

type Engine

type Engine struct {
	OracleDB *sql.DB
	MysqlDB  *sql.DB
	GormDB   *gorm.DB
}

定义数据库引擎

func (*Engine) AddOracleLogminerlogFile

func (e *Engine) AddOracleLogminerlogFile(logFile string) error

func (*Engine) BatchWriteMySQLTableData added in v1.0.4

func (e *Engine) BatchWriteMySQLTableData(targetSchemaName, targetTableName, insertPrepareSql string, args [][]interface{}, applyThreads int) error

批量 Batch

func (*Engine) CloseOracleChunkTask added in v1.0.4

func (e *Engine) CloseOracleChunkTask(taskName string) error

func (*Engine) DeleteWaitSyncTableMetaRecord added in v1.0.4

func (e *Engine) DeleteWaitSyncTableMetaRecord(metaSchemaName, sourceSchemaName, sourceTableName, syncMode string) error

func (*Engine) EndOracleLogminerStoredProcedure

func (e *Engine) EndOracleLogminerStoredProcedure() error

func (*Engine) FilterDifferenceOracleTable

func (e *Engine) FilterDifferenceOracleTable(schemaName string, excludeTables []string) ([]string, error)

func (*Engine) FilterIntersectionMySQLTable

func (e *Engine) FilterIntersectionMySQLTable(schemaName string, includeTables []string) ([]string, error)

func (*Engine) FilterOracleClusteredTable added in v1.0.4

func (e *Engine) FilterOracleClusteredTable(schemaName string, tableSlice []string) ([]string, error)

func (*Engine) FilterOraclePartitionTable

func (e *Engine) FilterOraclePartitionTable(schemaName string, tableSlice []string) ([]string, error)

func (*Engine) FilterOracleTemporaryTable added in v1.0.4

func (e *Engine) FilterOracleTemporaryTable(schemaName string, tableSlice []string) ([]string, error)

func (*Engine) GetColumnRuleMap added in v1.0.4

func (e *Engine) GetColumnRuleMap(schemaName, tableName string) ([]ColumnRuleMap, error)

func (*Engine) GetDefaultValueMap added in v1.0.4

func (e *Engine) GetDefaultValueMap() ([]DefaultValueMap, error)

func (*Engine) GetFinishFullSyncMetaRecord added in v1.0.4

func (e *Engine) GetFinishFullSyncMetaRecord(schemaName string, syncMode string) ([]WaitSyncMeta, []string, error)

func (*Engine) GetFullSyncMetaRowIDRecord added in v1.0.4

func (e *Engine) GetFullSyncMetaRowIDRecord(schemaName, tableName string) ([]string, error)

func (*Engine) GetMySQLDBServerCharacterSet

func (e *Engine) GetMySQLDBServerCharacterSet() (string, error)

MySQL

func (*Engine) GetMySQLDBServerCollation

func (e *Engine) GetMySQLDBServerCollation() (string, error)

func (*Engine) GetMySQLDBVersion

func (e *Engine) GetMySQLDBVersion() (string, error)

func (*Engine) GetMySQLPartitionTableINFO

func (e *Engine) GetMySQLPartitionTableINFO(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetMySQLTableCharacterSetAndCollation

func (e *Engine) GetMySQLTableCharacterSetAndCollation(schemaName, tableName string) (string, string, error)

func (*Engine) GetMySQLTableCheckKey

func (e *Engine) GetMySQLTableCheckKey(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetMySQLTableColumn

func (e *Engine) GetMySQLTableColumn(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetMySQLTableComment

func (e *Engine) GetMySQLTableComment(schemaName, tableName string) (string, error)

func (*Engine) GetMySQLTableForeignKey

func (e *Engine) GetMySQLTableForeignKey(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetMySQLTableIncrementMetaMinGlobalSCNTime

func (e *Engine) GetMySQLTableIncrementMetaMinGlobalSCNTime(sourceSchemaName string) (int, error)

func (*Engine) GetMySQLTableIncrementMetaMinSourceTableSCNTime

func (e *Engine) GetMySQLTableIncrementMetaMinSourceTableSCNTime(sourceSchemaName string) (int, error)

func (*Engine) GetMySQLTableIncrementMetaRecord

func (e *Engine) GetMySQLTableIncrementMetaRecord(sourceSchemaName string) ([]string, map[string]int, error)

func (*Engine) GetMySQLTableIndex

func (e *Engine) GetMySQLTableIndex(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetMySQLTablePrimaryAndUniqueKey

func (e *Engine) GetMySQLTablePrimaryAndUniqueKey(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleALLRedoLogFile

func (e *Engine) GetOracleALLRedoLogFile() ([]string, error)

func (*Engine) GetOracleArchivedLogFile

func (e *Engine) GetOracleArchivedLogFile(scn string) ([]map[string]string, error)

func (*Engine) GetOracleArchivedLogSCN

func (e *Engine) GetOracleArchivedLogSCN(scn string) (int, error)

func (*Engine) GetOracleAvgRowLength

func (e *Engine) GetOracleAvgRowLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleCodeObject

func (e *Engine) GetOracleCodeObject(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleColumnTypeAndMaxLength

func (e *Engine) GetOracleColumnTypeAndMaxLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleConstraintType

func (e *Engine) GetOracleConstraintType(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleCurrentRedoMaxSCN

func (e *Engine) GetOracleCurrentRedoMaxSCN() (int, int, string, error)

func (*Engine) GetOracleCurrentSnapshotSCN

func (e *Engine) GetOracleCurrentSnapshotSCN() (int, error)

func (*Engine) GetOracleDBCharacterSet

func (e *Engine) GetOracleDBCharacterSet() (string, error)

Oracle

func (*Engine) GetOracleDBName

func (e *Engine) GetOracleDBName() (string, string, string, error)

func (*Engine) GetOracleDataTotal

func (e *Engine) GetOracleDataTotal() (string, error)

func (*Engine) GetOracleGlobalName

func (e *Engine) GetOracleGlobalName() (string, error)

func (*Engine) GetOracleIndexType

func (e *Engine) GetOracleIndexType(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleInstance

func (e *Engine) GetOracleInstance() ([]map[string]string, error)

func (*Engine) GetOracleLogminerContentToMySQL

func (e *Engine) GetOracleLogminerContentToMySQL(schemaName string, sourceTableNameList string, lastCheckpoint string, logminerQueryTimeout int) ([]LogminerContent, error)

func (*Engine) GetOracleMemoryGB

func (e *Engine) GetOracleMemoryGB() (string, error)

func (*Engine) GetOracleNumCPU

func (e *Engine) GetOracleNumCPU() (string, error)

func (*Engine) GetOracleObjectTypeOverview

func (e *Engine) GetOracleObjectTypeOverview(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleParameters

func (e *Engine) GetOracleParameters() (string, string, string, string, error)

func (*Engine) GetOraclePartitionObjectType

func (e *Engine) GetOraclePartitionObjectType(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOraclePartitionTableINFO

func (e *Engine) GetOraclePartitionTableINFO(schemaName, tableName string) ([]map[string]string, error)

func (*Engine) GetOraclePartitionTableOver1024

func (e *Engine) GetOraclePartitionTableOver1024(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleRedoLogFile

func (e *Engine) GetOracleRedoLogFile(scn string) ([]map[string]string, error)

func (*Engine) GetOracleRedoLogSCN

func (e *Engine) GetOracleRedoLogSCN(scn string) (int, error)

func (*Engine) GetOracleSchemaOverview

func (e *Engine) GetOracleSchemaOverview(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleSchemaTableRowsTOP

func (e *Engine) GetOracleSchemaTableRowsTOP(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleSynonymObjectType

func (e *Engine) GetOracleSynonymObjectType(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTable

func (e *Engine) GetOracleTable(schemaName string) ([]string, error)

func (*Engine) GetOracleTableCheckKey

func (e *Engine) GetOracleTableCheckKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableChunksByRowID added in v1.0.4

func (e *Engine) GetOracleTableChunksByRowID(taskName, schemaName, tableName string, globalSCN, insertBatchSize int, isPartition string) (int, error)

func (*Engine) GetOracleTableColumn

func (e *Engine) GetOracleTableColumn(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableColumnCountsOver512

func (e *Engine) GetOracleTableColumnCountsOver512(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableColumnNameLength

func (e *Engine) GetOracleTableColumnNameLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableComment

func (e *Engine) GetOracleTableComment(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableForeignKey

func (e *Engine) GetOracleTableForeignKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableIndexCountsOver64

func (e *Engine) GetOracleTableIndexCountsOver64(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableIndexLengthOver3072

func (e *Engine) GetOracleTableIndexLengthOver3072(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableIndexNameLength

func (e *Engine) GetOracleTableIndexNameLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableNameLength

func (e *Engine) GetOracleTableNameLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableNormalIndex added in v1.0.4

func (e *Engine) GetOracleTableNormalIndex(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableNumberTypeCheck

func (e *Engine) GetOracleTableNumberTypeCheck(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTablePrimaryKey

func (e *Engine) GetOracleTablePrimaryKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableRecordByRowIDSQL

func (e *Engine) GetOracleTableRecordByRowIDSQL(sql string) ([]string, []interface{}, error)

func (*Engine) GetOracleTableRowLengthOver6M

func (e *Engine) GetOracleTableRowLengthOver6M(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableRows added in v1.0.4

func (e *Engine) GetOracleTableRows(querySQL string) ([]string, []interface{}, error)

获取表字段名以及行数据

func (*Engine) GetOracleTableSequenceNameLength

func (e *Engine) GetOracleTableSequenceNameLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTableType added in v1.0.4

func (e *Engine) GetOracleTableType(schemaName string) (map[string]string, error)

func (*Engine) GetOracleTableUniqueIndex added in v1.0.4

func (e *Engine) GetOracleTableUniqueIndex(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableUniqueKey

func (e *Engine) GetOracleTableUniqueKey(schemaName string, tableName string) ([]map[string]string, error)

func (*Engine) GetOracleTableViewNameLength

func (e *Engine) GetOracleTableViewNameLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleTemporaryTable

func (e *Engine) GetOracleTemporaryTable(schemaName []string) ([]map[string]string, error)

func (*Engine) GetOracleUsernameLength

func (e *Engine) GetOracleUsernameLength(schemaName []string) ([]map[string]string, error)

func (*Engine) GetPartSyncTableMetaRecord added in v1.0.4

func (e *Engine) GetPartSyncTableMetaRecord(sourceSchema, syncMode string) ([]WaitSyncMeta, []string, error)

获取全量待同步表信息

func (*Engine) GetSchemaRuleMap added in v1.0.4

func (e *Engine) GetSchemaRuleMap(schemaName string) ([]SchemaRuleMap, error)

func (*Engine) GetTableRuleMap added in v1.0.4

func (e *Engine) GetTableRuleMap(schemaName, tableName string) ([]TableRuleMap, error)

func (*Engine) GetWaitSyncTableMetaRecord added in v1.0.4

func (e *Engine) GetWaitSyncTableMetaRecord(sourceSchema, syncMode string) ([]WaitSyncMeta, []string, error)

func (*Engine) InitDefaultValueMap added in v1.0.4

func (e *Engine) InitDefaultValueMap() error

func (*Engine) InitIncrementSyncMetaRecord added in v1.0.4

func (e *Engine) InitIncrementSyncMetaRecord(schemaName, tableName, isPartition string, globalSCN int) error

func (*Engine) InitMysqlEngineDB

func (e *Engine) InitMysqlEngineDB() error

初始化同步表结构

func (*Engine) InitWaitAndFullSyncMetaRecord added in v1.0.4

func (e *Engine) InitWaitAndFullSyncMetaRecord(schemaName, tableName string, workerID, globalSCN int, chunkSize, insertBatchSize int, syncMode string) error

func (*Engine) InitWaitSyncTableMetaRecord added in v1.0.4

func (e *Engine) InitWaitSyncTableMetaRecord(schemaName string, tableName []string, syncMode string) error

func (*Engine) IsExistIncrementSyncMetaRecord added in v1.0.4

func (e *Engine) IsExistIncrementSyncMetaRecord(schemaName string, transferTableSlice []string) ([]string, []string, error)

func (*Engine) IsExistMySQLSchema

func (e *Engine) IsExistMySQLSchema(schemaName string) (bool, error)

func (*Engine) IsExistMySQLTable

func (e *Engine) IsExistMySQLTable(schemaName, tableName string) (bool, error)

func (*Engine) IsExistMySQLTableCharacterSetAndCollation

func (e *Engine) IsExistMySQLTableCharacterSetAndCollation(schemaName, tableName string) (bool, error)

func (*Engine) IsExistMysqlIndex

func (e *Engine) IsExistMysqlIndex(schemaName, tableName, indexName string) bool

func (*Engine) IsExistOracleSchema

func (e *Engine) IsExistOracleSchema(schemaName string) error

func (*Engine) IsExistOracleTable

func (e *Engine) IsExistOracleTable(schemaName string, includeTables []string) error

func (*Engine) IsExistWaitSyncTableMetaRecord added in v1.0.4

func (e *Engine) IsExistWaitSyncTableMetaRecord(schemaName string, tableName, syncMode string) (bool, error)

func (*Engine) IsFinishFullSyncMetaRecord added in v1.0.4

func (e *Engine) IsFinishFullSyncMetaRecord(schemaName string, transferTableSlice []string, syncMode string) ([]string, error)

func (*Engine) IsMySQLPartitionTable

func (e *Engine) IsMySQLPartitionTable(schemaName, tableName string) (bool, error)

func (*Engine) IsOraclePartitionTable

func (e *Engine) IsOraclePartitionTable(schemaName, tableName string) (bool, error)

func (*Engine) JudgingCheckpointResume added in v1.0.4

func (e *Engine) JudgingCheckpointResume(schemaName string, tableMetas []WaitSyncMeta) ([]string, error)

该函数只应用于全量同步模式或者 ALL 同步模式 1、断点续传判断,判断是否可进行断点续传 2、判断是否存在未初始化元信息的表

func (*Engine) ModifyWaitAndFullSyncTableMetaRecord added in v1.0.4

func (e *Engine) ModifyWaitAndFullSyncTableMetaRecord(metaSchemaName, sourceSchemaName, sourceTableName, rowidSQL, syncMode string) error

清理并更新同步任务元数据表 1、全量每成功同步一张表记录,再清理记录 2、更新同步数据表元信息

func (*Engine) RenameMySQLTableName

func (e *Engine) RenameMySQLTableName(schemaName string, tableName string) error

func (*Engine) StartOracleChunkCreateTask added in v1.0.4

func (e *Engine) StartOracleChunkCreateTask(taskName string) error

func (*Engine) StartOracleCreateChunkByRowID added in v1.0.4

func (e *Engine) StartOracleCreateChunkByRowID(taskName, schemaName, tableName string, chunkSize string) error

func (*Engine) StartOracleLogminerStoredProcedure

func (e *Engine) StartOracleLogminerStoredProcedure(scn string) error

func (*Engine) TruncateFullSyncTableMetaRecord added in v1.0.4

func (e *Engine) TruncateFullSyncTableMetaRecord(metaSchemaName string) error

清理全量同步任务元数据表

func (*Engine) TruncateMySQLTableRecord

func (e *Engine) TruncateMySQLTableRecord(targetSchemaName string, tableName string) error

func (*Engine) UpdateSingleTableIncrementMetaSCNByArchivedLog

func (e *Engine) UpdateSingleTableIncrementMetaSCNByArchivedLog(
	sourceSchemaName string, logFileEndSCN int, transferTableSlice []string) error

func (*Engine) UpdateSingleTableIncrementMetaSCNByCurrentRedo

func (e *Engine) UpdateSingleTableIncrementMetaSCNByCurrentRedo(
	sourceSchemaName string, lastRedoLogMaxSCN, logFileStartSCN, logFileEndSCN int) error

func (*Engine) UpdateSingleTableIncrementMetaSCNByNonCurrentRedo

func (e *Engine) UpdateSingleTableIncrementMetaSCNByNonCurrentRedo(
	sourceSchemaName string, lastRedoLogMaxSCN, logFileStartSCN, logFileEndSCN int, transferTableSlice []string) error

func (*Engine) UpdateTableIncrementMetaALLSCNRecord

func (e *Engine) UpdateTableIncrementMetaALLSCNRecord(sourceSchemaName, sourceTableName, operationType string, globalSCN, sourceTableSCN int) error

func (*Engine) UpdateWaitSyncMetaTableRecord added in v1.0.4

func (e *Engine) UpdateWaitSyncMetaTableRecord(schemaName, tableName string, rowCounts, globalSCN int, isPartition, syncMode string) error

type FullConfig

type FullConfig struct {
	ChunkSize        int  `toml:"chunk-size" json:"chunk-size"`
	WorkerThreads    int  `toml:"worker-threads" json:"worker-threads"`
	TableThreads     int  `toml:"table-threads" json:"table-threads"`
	EnableCheckpoint bool `toml:"enable-checkpoint" json:"enable-checkpoint"`
	ApplyThreads     int  `toml:"apply-threads" json:"apply-threads"`
}

type FullSyncMeta added in v1.0.4

type FullSyncMeta struct {
	ID               uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	SourceSchemaName string     `gorm:"not null;index:idx_schema_table_rowid;comment:'源端 schema'" json:"source_schema_name"`
	SourceTableName  string     `gorm:"not null;index:idx_schema_table_rowid;comment:'源端表名'" json:"source_table_name"`
	GlobalSCN        int        `gorm:"comment:'全局 SCN'" json:"global_scn"`
	RowidSQL         string     `gorm:"not null;index:idx_schema_table_rowid;comment:'表 rowid 切分SQL'" json:"rowid_sql"`
	IsPartition      string     `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	CreatedAt        *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt        *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}

全量同步元数据表

func (*FullSyncMeta) GetFullSyncMetaRecordCounts added in v1.0.4

func (f *FullSyncMeta) GetFullSyncMetaRecordCounts(schemaName, tableName string, engine *Engine) (int, error)

type GormLogger

type GormLogger struct {
	ZapLogger        *zap.Logger
	LogLevel         gormLogger.LogLevel
	SlowThreshold    time.Duration
	SkipCallerLookup bool
	Colorful         bool
}

func NewGormLogger

func NewGormLogger(zapLogger *zap.Logger, slowThreshold time.Duration) GormLogger

func (GormLogger) Error

func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})

func (GormLogger) Info

func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})

func (GormLogger) LogMode

func (GormLogger) SetAsDefault

func (l GormLogger) SetAsDefault()

func (GormLogger) Trace

func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (GormLogger) Warn

func (l GormLogger) Warn(ctx context.Context, str string, args ...interface{})

type IncrementSyncMeta added in v1.0.4

type IncrementSyncMeta struct {
	ID               uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	GlobalSCN        int        `gorm:"comment:'全局 SCN'" json:"global_scn"`
	SourceSchemaName string     `gorm:"not null;index:unique_schema_table,unique;comment:'源端 schema'" json:"source_schema_name"`
	SourceTableName  string     `gorm:"not null;index:unique_schema_table,unique;comment:'源端表名'" json:"source_table_name"`
	SourceTableSCN   int        `gorm:"comment:'表同步 SCN'" json:"source_table_scn"`
	IsPartition      string     `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	CreatedAt        *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt        *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}

增量同步元数据表

func (*IncrementSyncMeta) GetIncrementSyncMetaRecordCounts added in v1.0.4

func (f *IncrementSyncMeta) GetIncrementSyncMetaRecordCounts(schemaName, tableName string, engine *Engine) (int, error)

type LogConfig

type LogConfig struct {
	LogLevel   string `toml:"log-level" json:"log-level"`
	LogFile    string `toml:"log-file" json:"log-file"`
	MaxSize    int    `toml:"max-size" json:"max-size"`
	MaxDays    int    `toml:"max-days" json:"max-days"`
	MaxBackups int    `toml:"max-backups" json:"max-backups"`
}

type LogminerContent

type LogminerContent struct {
	SCN       int
	SegOwner  string
	TableName string
	SQLRedo   string
	SQLUndo   string
	Operation string
}

获取 Oracle logminer 日志内容并过滤筛选已提交的 INSERT/DELETE/UPDATE 事务语句 考虑异构数据库,只同步 INSERT/DELETE/UPDATE 事务语句以及 TRUNCATE TABLE/DROP TABLE DDL 语句,其他类型 SQL 不同步 V$LOGMNR_CONTENTS 字段解释参考链接 https://docs.oracle.com/en/database/oracle/oracle-database/21/refrn/V-LOGMNR_CONTENTS.html#GUID-B9196942-07BF-4935-B603-FA875064F5C3

type SchemaRuleMap added in v1.0.4

type SchemaRuleMap struct {
	ID               uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	SourceSchemaName string     `gorm:"not null;index:unique_schema_col,unique;comment:'源端库 schema'" json:"source_schema_name"`
	SourceColumnType string     `gorm:"not null;index:unique_schema_col,unique;comment:'源端表字段类型'" json:"source_column_type"`
	TargetColumnType string     `gorm:"not null;index:idx_target_col;comment:'目标表字段类型'" json:"target_column_type"`
	CreatedAt        *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt        *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}

自定义库转换规则 - schema 级别

func (*SchemaRuleMap) AdjustSchemaDataType added in v1.0.4

func (c *SchemaRuleMap) AdjustSchemaDataType() string

type SourceConfig

type SourceConfig struct {
	Username      string   `toml:"username" json:"username"`
	Password      string   `toml:"password" json:"password"`
	ConnectString string   `toml:"connect-string",json:"connect-string"`
	SessionParams []string `toml:"session-params" json:"session-params"`
	Timezone      string   `toml:"timezone" json:"timezone"`
	SchemaName    string   `toml:"schema-name",json:"schema-name"`
	IncludeTable  []string `toml:"include-table",json:"include-table"`
	ExcludeTable  []string `toml:"exclude-table",json:"exclude-table"`
}

type TableRuleMap added in v1.0.4

type TableRuleMap struct {
	ID               uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	SourceSchemaName string     `gorm:"not null;index:unique_schema_table_col,unique;comment:'源端库 schema'" json:"source_schema_name"`
	SourceTableName  string     `gorm:"not null;index:unique_schema_table_col,unique;comment:'源端表名'" json:"source_table_name"`
	SourceColumnType string     `gorm:"not null;index:unique_schema_table_col,unique;comment:'源端表字段类型'" json:"source_column_type"`
	TargetColumnType string     `gorm:"not null;index:idx_target_col;comment:'目标表字段类型'" json:"target_column_type"`
	CreatedAt        *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt        *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}

自定义表转换规则 - table 级别

func (*TableRuleMap) AdjustTableDataType added in v1.0.4

func (c *TableRuleMap) AdjustTableDataType(tableName string) string

type TargetConfig

type TargetConfig struct {
	Username      string `toml:"username" json:"username"`
	Password      string `toml:"password" json:"password"`
	Host          string `toml:"host" json:"host"`
	Port          int    `toml:"port" json:"port"`
	ConnectParams string `toml:"connect-params" json:"connect-params"`
	MetaSchema    string `toml:"meta-schema" json:"meta-schema"`
	SchemaName    string `toml:"schema-name",json:"schema-name"`
	Overwrite     bool   `toml:"overwrite" json:"overwrite"`
}

type WaitSyncMeta added in v1.0.4

type WaitSyncMeta struct {
	ID               uint       `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"`
	SourceSchemaName string     `gorm:"not null;index:idx_schema_table,unique;comment:'源端 schema'" json:"source_schema_name"`
	SourceTableName  string     `gorm:"not null;index:idx_schema_table,unique;comment:'源端表名'" json:"source_table_name"`
	SyncMode         string     `gorm:"not null;index:idx_sync_mode;comment:'同步模式'" json:"sync_mode"`
	FullGlobalSCN    int        `gorm:"comment:'全量全局 SCN'" json:"full_global_scn"`
	FullSplitTimes   int        `gorm:"comment:'全量任务切分 SQL 次数'" json:"full_split_times"`
	IsPartition      string     `gorm:"comment:'是否是分区表'" json:"is_partition"` // 同步转换统一转换成非分区表,此处只做标志
	CreatedAt        *time.Time `gorm:"type:timestamp;not null;default:current_timestamp;comment:'创建时间'" json:"createdAt"`
	UpdatedAt        *time.Time `gorm:"type:timestamp;not null on update current_timestamp;default:current_timestamp;comment:'更新时间'" json:"updatedAt"`
}

同步元数据表

Jump to

Keyboard shortcuts

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