Documentation ¶
Index ¶
- Variables
- func BinlogName(index uint64) string
- func CheckMagic(mgicNum uint32) error
- func CloseBinlogger(binlogger Binlogger) error
- func CreateDirAll(dir string) error
- func Decode(r io.Reader) (payload []byte, length int64, err error)
- func Encode(payload []byte) []byte
- func Exist(name string) bool
- func FilterBinlogNames(names []string) []string
- func InitMetircs(registry *prometheus.Registry)
- func IsValidBinlog(names []string) bool
- func ParseBinlogName(str string) (index uint64, ts int64, err error)
- func ReadBinlogNames(dirpath string) ([]string, error)
- func ReadDir(dirpath string) ([]string, error)
- func SearchIndex(names []string, index uint64) (int, bool)
- type Binlogger
- type Decoder
- type Encoder
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrFileContentCorruption represents file or directory's content is curruption for some season ErrFileContentCorruption = errors.New("binlogger: content is corruption") // ErrCRCMismatch is the error represents crc don't match ErrCRCMismatch = errors.New("binlogger: crc mismatch") // ErrMagicMismatch is the error represents magic don't match ErrMagicMismatch = errors.New("binlogger: magic mismatch") // SegmentSizeBytes is the max file size of file SegmentSizeBytes int64 = 512 * 1024 * 1024 )
View Source
var ( // ErrBadBinlogName is an error represents invalid file name. ErrBadBinlogName = errors.New("bad file name") // ErrFileNotFound is an error represents binlog file not found ErrFileNotFound = errors.New("binlogger: file not found") )
Functions ¶
func BinlogName ¶
BinlogName creates a binlog file name. The file name format is like binlog-0000000000000001-20181010101010
func CheckMagic ¶
CheckMagic check weather the magicNum is right
func CloseBinlogger ¶
CloseBinlogger closes the binlogger
func CreateDirAll ¶
CreateDirAll guarantees to create a new and empty dir
func FilterBinlogNames ¶
FilterBinlogNames filter binlog names from names.
func InitMetircs ¶
func InitMetircs(registry *prometheus.Registry)
InitMetircs register the metrics to registry
func IsValidBinlog ¶
IsValidBinlog detects the binlog names is valid
func ParseBinlogName ¶
ParseBinlogName parse binlog file name and return binlog index.
func ReadBinlogNames ¶
ReadBinlogNames returns sorted filenames in the dirpath
Types ¶
type Binlogger ¶
type Binlogger interface { // read nums binlog events from the "from" position ReadFrom(from binlog.Pos, nums int32) ([]binlog.Entity, error) // ReadAll reads all binlog in the directory. ReadAll(ctx context.Context) (<-chan *binlog.Entity, <-chan error) // batch write binlog event, and returns current offset(if have). WriteTail(entity *binlog.Entity) (binlog.Pos, error) // Walk reads binlog from the "from" position and sends binlogs in the streaming way Walk(ctx context.Context, from binlog.Pos, sendBinlog func(entity *binlog.Entity) error) error // close the binlogger Close() error // GGCByTime delete all files that's older than the specified duration, the latest file is always kept GCByTime(retentionTime time.Duration) // GCByPos delete all files that's before the specified position, the latest file is always kept GCByPos(pos binlog.Pos) }
Binlogger is the interface that for append and read binlog
Click to show internal directories.
Click to hide internal directories.