incrdump

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package incrdum provides helper functions for incremental change capture.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncrDump

func IncrDump(
	ctx context.Context,
	cfg *IncrDumpConfig,
	gtidSet string,
	handler Handler,
) error

IncrDump reads events from mysql binlog, see mycanal's doc for prerequisites

Types

type Handler

type Handler func(ctx context.Context, e interface{}) error

Handler is used to handle events in binlog, can be one of the followings:

  • *TrxBeginning: the beginning of a gtid trx
  • *TrxEnding: the end of a gtid trx
  • *RowInsertion: row insert, between TrxBeginning/TrxEnding
  • *RowUpdating: row update, between TrxBeginning/TrxEnding
  • *RowDeletion: row delete, between TrxBeginning/TrxEnding

Maybe more events will be added in the future

type RowChange

type RowChange interface {
	TrxEvent

	// SchemaName returns the database name.
	SchemaName() string

	// TableName returns the table name.
	TableName() string

	// ColumnNames returns column names of the table.
	ColumnNames() []string

	// BeforeData returns column data before the change or nil if not applicable.
	BeforeData() []interface{}

	// BeforeDataMap returns data map (column name -> column data)
	// before the change or nil if not applicable.
	BeforeDataMap() map[string]interface{}

	// AfterData returns column data after the change or nil if not applicable.
	AfterData() []interface{}

	// AfterDataMap returns data map (column name -> column data)
	// after the change or nil if not applicable.
	AfterDataMap() map[string]interface{}
}

RowChange is the common interface of RowInsertion/RowUpdating/RowDeletion.

type RowDeletion

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

RowDeletion represents a row deletion.

func (RowDeletion) AfterData

func (e RowDeletion) AfterData() []interface{}

AfterData returns column data after the change or nil if not applicable.

func (RowDeletion) AfterDataMap

func (e RowDeletion) AfterDataMap() map[string]interface{}

AfterDataMap returns data map (column name -> column data) after the change or nil if not applicable.

func (RowDeletion) BeforeData

func (e RowDeletion) BeforeData() []interface{}

BeforeData returns column data before the change or nil if not applicable.

func (RowDeletion) BeforeDataMap

func (e RowDeletion) BeforeDataMap() map[string]interface{}

BeforeDataMap returns data map (column name -> column data) before the change or nil if not applicable.

func (RowDeletion) ColumnNames

func (e RowDeletion) ColumnNames() []string

ColumnNames returns column names of the table.

func (RowDeletion) SchemaName

func (e RowDeletion) SchemaName() string

SchemaName returns the database name.

func (RowDeletion) TableName

func (e RowDeletion) TableName() string

TableName returns the table name.

func (RowDeletion) TrxContext

func (e RowDeletion) TrxContext() *TrxContext

TrxContext returns the trx context.

type RowInsertion

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

RowInsertion represents a row insertion.

func (RowInsertion) AfterData

func (e RowInsertion) AfterData() []interface{}

AfterData returns column data after the change or nil if not applicable.

func (RowInsertion) AfterDataMap

func (e RowInsertion) AfterDataMap() map[string]interface{}

AfterDataMap returns data map (column name -> column data) after the change or nil if not applicable.

func (RowInsertion) BeforeData

func (e RowInsertion) BeforeData() []interface{}

BeforeData returns column data before the change or nil if not applicable.

func (RowInsertion) BeforeDataMap

func (e RowInsertion) BeforeDataMap() map[string]interface{}

BeforeDataMap returns data map (column name -> column data) before the change or nil if not applicable.

func (RowInsertion) ColumnNames

func (e RowInsertion) ColumnNames() []string

ColumnNames returns column names of the table.

func (RowInsertion) SchemaName

func (e RowInsertion) SchemaName() string

SchemaName returns the database name.

func (RowInsertion) TableName

func (e RowInsertion) TableName() string

TableName returns the table name.

func (RowInsertion) TrxContext

func (e RowInsertion) TrxContext() *TrxContext

TrxContext returns the trx context.

type RowUpdating

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

RowUpdating represents a row updating.

func (RowUpdating) AfterData

func (e RowUpdating) AfterData() []interface{}

AfterData returns column data after the change or nil if not applicable.

func (RowUpdating) AfterDataMap

func (e RowUpdating) AfterDataMap() map[string]interface{}

AfterDataMap returns data map (column name -> column data) after the change or nil if not applicable.

func (RowUpdating) BeforeData

func (e RowUpdating) BeforeData() []interface{}

BeforeData returns column data before the change or nil if not applicable.

func (RowUpdating) BeforeDataMap

func (e RowUpdating) BeforeDataMap() map[string]interface{}

BeforeDataMap returns data map (column name -> column data) before the change or nil if not applicable.

func (RowUpdating) ColumnNames

func (e RowUpdating) ColumnNames() []string

ColumnNames returns column names of the table.

func (RowUpdating) SchemaName

func (e RowUpdating) SchemaName() string

SchemaName returns the database name.

func (RowUpdating) TableName

func (e RowUpdating) TableName() string

TableName returns the table name.

func (RowUpdating) TrxContext

func (e RowUpdating) TrxContext() *TrxContext

TrxContext returns the trx context.

type TrxBeginning

type TrxBeginning TrxContext

TrxBeginning represents the start of a trx.

func (*TrxBeginning) TrxContext

func (e *TrxBeginning) TrxContext() *TrxContext

TrxContext returns the trx context.

type TrxContext

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

TrxContext is the context of binlog trx.

func (*TrxContext) AfterGTIDSet

func (trxCtx *TrxContext) AfterGTIDSet() mysql.GTIDSet

AfterGTIDSet returns the gtid set after current trx.

func (*TrxContext) GTID

func (trxCtx *TrxContext) GTID() string

GTID returns the gtid for current trx.

func (*TrxContext) PrevGTIDSet

func (trxCtx *TrxContext) PrevGTIDSet() mysql.GTIDSet

PrevGTIDSet returns the gtid set before current trx.

type TrxEnding

type TrxEnding TrxContext

TrxEnding represents the end of a trx.

func (*TrxEnding) TrxContext

func (e *TrxEnding) TrxContext() *TrxContext

TrxContext returns the trx context.

type TrxEvent

type TrxEvent interface {
	// TrxContext returns the trx context.
	TrxContext() *TrxContext
}

TrxEvent represents event inside a trx.

Jump to

Keyboard shortcuts

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