report

package
v5.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Pass means all data and struct of tables are equal
	Pass = "pass"
	// Fail means not all data or struct of tables are equal
	Fail  = "fail"
	Error = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkResult

type ChunkResult struct {
	RowsAdd    int `json:"rows-add"`    // `RowsAdd` is the number of rows needed to add
	RowsDelete int `json:"rows-delete"` // `RowsDelete` is the number of rows needed to delete
}

ChunkResult save the necessarily information to provide summary information

type Report

type Report struct {
	sync.RWMutex
	Result       string                             `json:"-"`             // Result is pass or fail
	PassNum      int32                              `json:"-"`             // The pass number of tables
	FailedNum    int32                              `json:"-"`             // The failed number of tables
	TableResults map[string]map[string]*TableResult `json:"table-results"` // TableResult saved the map of  `schema` => `table` => `tableResult`
	StartTime    time.Time                          `json:"start-time"`
	Duration     time.Duration                      `json:"time-duration"`
	TotalSize    int64                              `json:"-"` // Total size of the checked tables
	SourceConfig [][]byte                           `json:"-"`
	TargetConfig []byte                             `json:"-"`
	// contains filtered or unexported fields
}

Report saves the check results.

func NewReport

func NewReport(task *config.TaskConfig) *Report

NewReport returns a new Report.

func (*Report) CalculateTotalSize

func (r *Report) CalculateTotalSize(ctx context.Context, db *sql.DB)

CalculateTotalSize calculate the total size of all the checked tables Notice, user should run the analyze table first, when some of tables' size are zero.

func (*Report) CommitSummary

func (r *Report) CommitSummary() error

CommitSummary commit summary info

func (*Report) GetSnapshot

func (r *Report) GetSnapshot(chunkID *chunk.ChunkID, schema, table string) (*Report, error)

GetSnapshot get the snapshot of the current state of the report, then we can restart the sync-diff and get the correct report state.

func (*Report) Init

func (r *Report) Init(tableDiffs []*common.TableDiff, sourceConfig [][]byte, targetConfig []byte)

func (*Report) LoadReport

func (r *Report) LoadReport(reportInfo *Report)

LoadReport loads the report from the checkpoint

func (*Report) Print

func (r *Report) Print(w io.Writer) error

func (*Report) SetTableDataCheckResult

func (r *Report) SetTableDataCheckResult(schema, table string, equal bool, rowsAdd, rowsDelete int, upCount, downCount int64, id *chunk.ChunkID)

SetTableDataCheckResult sets the data check result for table.

func (*Report) SetTableMeetError

func (r *Report) SetTableMeetError(schema, table string, err error)

SetTableMeetError sets meet error when check the table.

func (*Report) SetTableStructCheckResult

func (r *Report) SetTableStructCheckResult(schema, table string, equal bool, skip bool)

SetTableStructCheckResult sets the struct check result for table.

type ReportConfig

type ReportConfig struct {
	Host     string `toml:"host"`
	Port     int    `toml:"port"`
	User     string `toml:"user"`
	Snapshot string `toml:"snapshot,omitempty"`
	SqlMode  string `toml:"sql-mode,omitempty"`
}

ReportConfig stores the config information for the user

type TableResult

type TableResult struct {
	Schema      string                  `json:"schema"`
	Table       string                  `json:"table"`
	StructEqual bool                    `json:"struct-equal"`
	DataSkip    bool                    `json:"data-skip"`
	DataEqual   bool                    `json:"data-equal"`
	MeetError   error                   `json:"-"`
	ChunkMap    map[string]*ChunkResult `json:"chunk-result"` // `ChunkMap` stores the `ChunkResult` of each chunk of the table
	UpCount     int64                   `json:"up-count"`     // `UpCount` is the number of rows in the table from upstream
	DownCount   int64                   `json:"down-count"`   // `DownCount` is the number of rows in the table from downstream

}

TableResult saves the check result for every table.

Jump to

Keyboard shortcuts

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