writer

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileConfig

type FileConfig struct {
	RelayDir string // directory to store relay log files.
	Filename string // the startup relay log filename, if not set then a fake RotateEvent must be the first event.
}

FileConfig is the configuration used by the FileWriter.

type FileWriter

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

FileWriter implements Writer interface.

func (*FileWriter) Close

func (w *FileWriter) Close() error

Close implements Writer.Close.

func (*FileWriter) Flush

func (w *FileWriter) Flush() error

Flush implements Writer.Flush.

func (*FileWriter) Recover

func (w *FileWriter) Recover() (RecoverResult, error)

Recover implements Writer.Recover.

func (*FileWriter) Start

func (w *FileWriter) Start() error

Start implements Writer.Start.

func (*FileWriter) WriteEvent

func (w *FileWriter) WriteEvent(ev *replication.BinlogEvent) (Result, error)

WriteEvent implements Writer.WriteEvent.

type RecoverResult

type RecoverResult struct {
	// true if recover operation has done and successfully.
	// false if no recover operation has done or unsuccessfully.
	Recovered bool
	// the latest binlog position after recover operation has done.
	LatestPos gmysql.Position
	// the latest binlog GTID set after recover operation has done.
	LatestGTIDs gtid.Set
}

RecoverResult represents a result for a binlog recover operation.

type Result

type Result struct {
	Ignore       bool   // whether the event ignored by the writer
	IgnoreReason string // why the writer ignore the event
}

Result represents a write result.

type Writer

type Writer interface {
	// Start prepares the writer for writing binlog events.
	Start() error

	// Close closes the writer and release the resource.
	Close() error

	// Recover tries to recover the binlog file or any other memory structure associate with this writer.
	// It is often used to recover a binlog file with some corrupt/incomplete binlog events/transactions at the end of the file.
	// It is not safe for concurrent use by multiple goroutines.
	// It should be called before writing to the file.
	Recover() (RecoverResult, error)

	// WriteEvent writes an binlog event's data into disk or any other places.
	// It is not safe for concurrent use by multiple goroutines.
	WriteEvent(ev *replication.BinlogEvent) (Result, error)

	// Flush flushes the buffered data to a stable storage or sends through the network.
	// It is not safe for concurrent use by multiple goroutines.
	Flush() error
}

Writer writes binlog events into disk or any other memory structure. The writer should support:

  1. write binlog events and report the operation result
  2. skip any obsolete binlog events
  3. generate dummy events to fill the gap if needed
  4. rotate binlog(relay) file if needed
  5. rollback/discard unfinished binlog entries(events or transactions)

func NewFileWriter

func NewFileWriter(tctx *tcontext.Context, cfg *FileConfig, parser2 *parser.Parser) Writer

NewFileWriter creates a FileWriter instances.

Jump to

Keyboard shortcuts

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