rpl

package
v0.0.0-...-5d7fbfc Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidLogID uint64 = 0
)
View Source
const LogHeadSize = 17

Variables

View Source
var (
	ErrLogNotFound    = errors.New("log not found")
	ErrStoreLogID     = errors.New("log id is less")
	ErrNoBehindLog    = errors.New("no behind commit log")
	ErrCommitIDBehind = errors.New("commit id is behind last log id")
)

Functions

This section is empty.

Types

type FileStore

type FileStore struct {
	LogStore
	// contains filtered or unexported fields
}

func NewFileStore

func NewFileStore(base string, cfg *config.Config) (*FileStore, error)

func (*FileStore) Clear

func (s *FileStore) Clear() error

func (*FileStore) Close

func (s *FileStore) Close() error

func (*FileStore) FirstID

func (s *FileStore) FirstID() (uint64, error)

func (*FileStore) GetLog

func (s *FileStore) GetLog(id uint64, l *Log) error

func (*FileStore) LastID

func (s *FileStore) LastID() (uint64, error)

func (*FileStore) PurgeExpired

func (s *FileStore) PurgeExpired(n int64) error

func (*FileStore) StoreLog

func (s *FileStore) StoreLog(l *Log) error

func (*FileStore) Sync

func (s *FileStore) Sync() error

type GoLevelDBStore

type GoLevelDBStore struct {
	LogStore
	// contains filtered or unexported fields
}

func NewGoLevelDBStore

func NewGoLevelDBStore(base string, syncLog int) (*GoLevelDBStore, error)

func (*GoLevelDBStore) Clear

func (s *GoLevelDBStore) Clear() error

func (*GoLevelDBStore) Close

func (s *GoLevelDBStore) Close() error

func (*GoLevelDBStore) FirstID

func (s *GoLevelDBStore) FirstID() (uint64, error)

func (*GoLevelDBStore) GetLog

func (s *GoLevelDBStore) GetLog(id uint64, log *Log) error

func (*GoLevelDBStore) LastID

func (s *GoLevelDBStore) LastID() (uint64, error)

func (*GoLevelDBStore) PurgeExpired

func (s *GoLevelDBStore) PurgeExpired(n int64) error

func (*GoLevelDBStore) StoreLog

func (s *GoLevelDBStore) StoreLog(log *Log) error

func (*GoLevelDBStore) Sync

func (s *GoLevelDBStore) Sync() error

type Log

type Log struct {
	ID          uint64
	CreateTime  uint32
	Compression uint8

	Data []byte
}

func (*Log) Decode

func (l *Log) Decode(r io.Reader) error

func (*Log) DecodeAt

func (l *Log) DecodeAt(r io.ReaderAt, pos int64) error

func (*Log) DecodeHead

func (l *Log) DecodeHead(r io.Reader) (uint32, error)

func (*Log) DecodeHeadAt

func (l *Log) DecodeHeadAt(r io.ReaderAt, pos int64) (uint32, error)

func (*Log) Encode

func (l *Log) Encode(w io.Writer) error

func (*Log) HeadSize

func (l *Log) HeadSize() int

func (*Log) Marshal

func (l *Log) Marshal() ([]byte, error)

func (*Log) Size

func (l *Log) Size() int

func (*Log) Unmarshal

func (l *Log) Unmarshal(b []byte) error

type LogStore

type LogStore interface {
	GetLog(id uint64, log *Log) error

	FirstID() (uint64, error)
	LastID() (uint64, error)

	// if log id is less than current last id, return error
	StoreLog(log *Log) error

	// Delete logs before n seconds
	PurgeExpired(n int64) error

	Sync() error

	// Clear all logs
	Clear() error

	Close() error
}

type Replication

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

func NewReplication

func NewReplication(cfg *config.Config) (*Replication, error)

func (*Replication) Clear

func (r *Replication) Clear() error

func (*Replication) ClearWithCommitID

func (r *Replication) ClearWithCommitID(id uint64) error

func (*Replication) Close

func (r *Replication) Close() error

func (*Replication) CommitIDBehind

func (r *Replication) CommitIDBehind() (bool, error)

func (*Replication) FirstLogID

func (r *Replication) FirstLogID() (uint64, error)

func (*Replication) GetLog

func (r *Replication) GetLog(id uint64, log *Log) error

func (*Replication) LastCommitID

func (r *Replication) LastCommitID() (uint64, error)

func (*Replication) LastLogID

func (r *Replication) LastLogID() (uint64, error)

func (*Replication) Log

func (r *Replication) Log(data []byte) (*Log, error)

func (*Replication) NextNeedCommitLog

func (r *Replication) NextNeedCommitLog(log *Log) error

func (*Replication) Stat

func (r *Replication) Stat() (*Stat, error)

func (*Replication) StoreLog

func (r *Replication) StoreLog(log *Log) error

func (*Replication) UpdateCommitID

func (r *Replication) UpdateCommitID(id uint64) error

func (*Replication) WaitLog

func (r *Replication) WaitLog() <-chan struct{}

type Stat

type Stat struct {
	FirstID  uint64
	LastID   uint64
	CommitID uint64
}

Jump to

Keyboard shortcuts

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