conversion

package
v1.0.1-0...-2c99dcb Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

TODO:(searce) Organize code in go style format to make this file more readable.

public constants first
key public type definitions next (although often it makes sense to put them next to public functions that use them)
then public functions (and relevant type definitions)
and helper functions and other non-public definitions last (generally in order of importance)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionConfig

func ConnectionConfig(sourceProfile profiles.SourceProfile) (interface{}, error)

func ReadSessionFile

func ReadSessionFile(conv *internal.Conv, sessionJSON string) error

ReadSessionFile reads a session JSON file and unmarshal it's content into *internal.Conv.

func ValidateTables

func ValidateTables(ctx context.Context, client *sp.Client, spDialect string) (string, error)

ValidateTables validates that all the tables in the database are empty. It returns the name of the first non-empty table if found, and an empty string otherwise.

func WriteBadData

func WriteBadData(bw *writer.BatchWriter, conv *internal.Conv, banner, name string, out *os.File)

WriteBadData prints summary stats about bad rows and writes detailed info to file 'name'.

func WriteConvGeneratedFiles

func WriteConvGeneratedFiles(conv *internal.Conv, dbName string, driver string, BytesRead int64, out *os.File) (string, error)

WriteConvGeneratedFiles creates a directory labeled downloads with the current timestamp where it writes the sessionfile, report summary and DDLs then returns the directory where it writes.

func WriteOverridesFile

func WriteOverridesFile(conv *internal.Conv, name string, out *os.File)

WriteOverridesFile writes the overrides file in JSON format.

func WriteSchemaFile

func WriteSchemaFile(conv *internal.Conv, now time.Time, name string, out *os.File, driver string)

WriteSchemaFile writes DDL statements in a file. It includes CREATE TABLE statements and ALTER TABLE statements to add foreign keys. The parameter name should end with a .txt.

func WriteSessionFile

func WriteSessionFile(conv *internal.Conv, name string, out *os.File)

WriteSessionFile writes conv struct to a file in JSON format.

Types

type ConnectionProfile

type ConnectionProfile struct {
	// Project Id of the resource
	ProjectId string
	// Datashard Id for the resource
	DatashardId string
	// Name of connection profile
	Id string
	// If true, don't create resource, only validate if creation is possible. If false, create resource.
	ValidateOnly bool
	// If true, create source connection profile, else create target connection profile and gcs bucket.
	IsSource bool
	// For source connection profile host of MySql instance
	Host string
	// For source connection profile port of MySql instance
	Port string
	// For source connection profile password of MySql instance
	Password string
	// For source connection profile user name of MySql instance
	User string
	// Region of connection profile to be created
	Region string
	// For target connection profile name of gcs bucket to be created
	BucketName string
}

type ConnectionProfileReq

type ConnectionProfileReq struct {
	ConnectionProfile ConnectionProfile
	Error             error
	Ctx               context.Context
}

type ConvImpl

type ConvImpl struct{}

func (*ConvImpl) DataConv

func (ci *ConvImpl) DataConv(ctx context.Context, migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile, ioHelper *utils.IOStreams, client *sp.Client, conv *internal.Conv, dataOnly bool, writeLimit int64, dataFromSource DataFromSourceInterface) (*writer.BatchWriter, error)

DataConv performs the data conversion The SourceProfile param provides the connection details to use the go SQL library.

func (*ConvImpl) SchemaConv

func (ci *ConvImpl) SchemaConv(migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile, ioHelper *utils.IOStreams, schemaFromSource SchemaFromSourceInterface) (*internal.Conv, error)

SchemaConv performs the schema conversion The SourceProfile param provides the connection details to use the go SQL library.

type ConvInterface

type ConvInterface interface {
	SchemaConv(migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile, ioHelper *utils.IOStreams, schemaFromSource SchemaFromSourceInterface) (*internal.Conv, error)
	DataConv(ctx context.Context, migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile, ioHelper *utils.IOStreams, client *sp.Client, conv *internal.Conv, dataOnly bool, writeLimit int64, dataFromSource DataFromSourceInterface) (*writer.BatchWriter, error)
}

type DataFromDatabaseImpl

type DataFromDatabaseImpl struct{}

type DataFromDatabaseInterface

type DataFromDatabaseInterface interface {
	// contains filtered or unexported methods
}

type DataFromSourceImpl

type DataFromSourceImpl struct{}

type DataFromSourceInterface

type DataFromSourceInterface interface {
	// contains filtered or unexported methods
}

type GetInfoImpl

type GetInfoImpl struct{}

func (*GetInfoImpl) GetInfoSchema

func (gi *GetInfoImpl) GetInfoSchema(migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile) (common.InfoSchema, error)

func (*GetInfoImpl) GetInfoSchemaFromCloudSQL

func (gi *GetInfoImpl) GetInfoSchemaFromCloudSQL(migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile) (common.InfoSchema, error)

type GetInfoInterface

type GetInfoInterface interface {
	GetInfoSchemaFromCloudSQL(migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile) (common.InfoSchema, error)
	GetInfoSchema(migrationProjectId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile) (common.InfoSchema, error)
	// contains filtered or unexported methods
}

type MockDataFromSource

type MockDataFromSource struct {
	mock.Mock
}

type MockGetInfo

type MockGetInfo struct {
	mock.Mock
}

func (*MockGetInfo) GetInfoSchema

func (mgi *MockGetInfo) GetInfoSchema(migrationShardId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile) (common.InfoSchema, error)

func (*MockGetInfo) GetInfoSchemaFromCloudSQL

func (mgi *MockGetInfo) GetInfoSchemaFromCloudSQL(migrationShardId string, sourceProfile profiles.SourceProfile, targetProfile profiles.TargetProfile) (common.InfoSchema, error)

type MockProcessDumpByDialect

type MockProcessDumpByDialect struct {
	mock.Mock
}

MockProcessDumpByDialect is a mock implementation of ProcessDumpByDialectInterface.

func (*MockProcessDumpByDialect) ProcessDump

func (m *MockProcessDumpByDialect) ProcessDump(driver string, conv *internal.Conv, r *internal.Reader) error

ProcessDump mocks the ProcessDump method of ProcessDumpByDialectInterface.

type MockResourceGeneration

type MockResourceGeneration struct {
	mock.Mock
}

func (*MockResourceGeneration) GetConnectionProfilesForResources

func (mrg *MockResourceGeneration) GetConnectionProfilesForResources(ctx context.Context, projectId string, sourceProfile profiles.SourceProfile, region string, validateOnly bool) ([]*ConnectionProfileReq, []*ConnectionProfileReq, error)

func (*MockResourceGeneration) PrepareMinimalDowntimeResources

func (mrg *MockResourceGeneration) PrepareMinimalDowntimeResources(createResourceData *ConnectionProfileReq, mutex *sync.Mutex) task.TaskResult[*ConnectionProfileReq]

func (*MockResourceGeneration) RollbackResourceCreation

func (mrg *MockResourceGeneration) RollbackResourceCreation(ctx context.Context, profiles []*ConnectionProfileReq) error

type MockSchemaFromSource

type MockSchemaFromSource struct {
	mock.Mock
}

func (*MockSchemaFromSource) SchemaFromDump

func (msads *MockSchemaFromSource) SchemaFromDump(SpProjectId string, SpInstanceId string, driver string, spDialect string, ioHelper *utils.IOStreams, processDump ProcessDumpByDialectInterface, defaultIdentityOptions profiles.DefaultIdentityOptions) (*internal.Conv, error)

type MockValidateOrCreateResources

type MockValidateOrCreateResources struct {
	mock.Mock
}

func (*MockValidateOrCreateResources) ValidateOrCreateResourcesForShardedMigration

func (mcr *MockValidateOrCreateResources) ValidateOrCreateResourcesForShardedMigration(ctx context.Context, projectId string, instanceName string, validateOnly bool, region string, sourceProfile profiles.SourceProfile) error

type MockValidateResources

type MockValidateResources struct {
	mock.Mock
}

func (*MockValidateResources) ValidateResourceGeneration

func (mvr *MockValidateResources) ValidateResourceGeneration(ctx context.Context, projectId string, instanceId string, sourceProfile profiles.SourceProfile, conv *internal.Conv) error

type PopulateDataConvImpl

type PopulateDataConvImpl struct{}

type PopulateDataConvInterface

type PopulateDataConvInterface interface {
	// contains filtered or unexported methods
}

type ProcessDumpByDialectImpl

type ProcessDumpByDialectImpl struct {
	ExpressionVerificationAccessor expressions_api.ExpressionVerificationAccessor
	DdlVerifier                    expressions_api.DDLVerifier
}

func (*ProcessDumpByDialectImpl) ProcessDump

func (pdd *ProcessDumpByDialectImpl) ProcessDump(driver string, conv *internal.Conv, r *internal.Reader) error

ProcessDump invokes process dump function from a sql package based on driver selected.

type ProcessDumpByDialectInterface

type ProcessDumpByDialectInterface interface {
	ProcessDump(driver string, conv *internal.Conv, r *internal.Reader) error
}

type ReportImpl

type ReportImpl struct{}

func (*ReportImpl) GenerateReport

func (r *ReportImpl) GenerateReport(driver string, badWrites map[string]int64, BytesRead int64, banner string, conv *internal.Conv, reportFileName string, dbName string, out *os.File)

Report generates a report of schema and data conversion.

type ReportInterface

type ReportInterface interface {
	GenerateReport(driver string, badWrites map[string]int64, BytesRead int64, banner string, conv *internal.Conv, reportFileName string, dbName string, out *os.File)
}

type SchemaFromSourceImpl

type SchemaFromSourceImpl struct {
	DdlVerifier expressions_api.DDLVerifier
}

func (*SchemaFromSourceImpl) SchemaFromDump

func (sads *SchemaFromSourceImpl) SchemaFromDump(SpProjectId string, SpInstanceId string, driver string, spDialect string, ioHelper *utils.IOStreams, processDump ProcessDumpByDialectInterface, defaultIdentityOptions profiles.DefaultIdentityOptions) (*internal.Conv, error)

type SchemaFromSourceInterface

type SchemaFromSourceInterface interface {
	SchemaFromDump(SpProjectId string, SpInstanceId string, driver string, spDialect string, ioHelper *utils.IOStreams, processDump ProcessDumpByDialectInterface, defaultIdentityOptions profiles.DefaultIdentityOptions) (*internal.Conv, error)
	// contains filtered or unexported methods
}

type SnapshotMigrationImpl

type SnapshotMigrationImpl struct{}

type SnapshotMigrationInterface

type SnapshotMigrationInterface interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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