wal_service

package
v0.0.0-...-7888d19 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnSupportMarshalTypeFormat = "it is not support to marshal for type[%T]"
)

Functions

func DefaultMarshalFunc

func DefaultMarshalFunc(data interface{}) []byte

DefaultMarshalFunc

Types

type ConsensusWalOption

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

func NewDefaultConsensusWalOption

func NewDefaultConsensusWalOption() ConsensusWalOption

type ConsensusWalOptionFunc

type ConsensusWalOptionFunc func(option *ConsensusWalOption)

func WithWriteMode

func WithWriteMode(walWriteMode WalWriteMode) ConsensusWalOptionFunc

func WithWritePath

func WithWritePath(walWritePath string) ConsensusWalOptionFunc

type MarshalFunc

type MarshalFunc func(data interface{}) []byte

MarshalFunc the function which marshal data to bytes if there is error when marshal, the process will panic

type WalOp

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

Wal Operate

type WalOpType

type WalOpType int
const (
	WalSyncOp WalOpType = iota
	WalWriteOp
	WalTruncateOp
	AsyncOpChanLength = 1024 * 16
)

type WalService

type WalService interface {
	// WalMode return wal write mode
	WalMode() WalWriteMode

	// Sync flush buffer into files
	Sync() error

	// LastIndex load the last index from wal file
	LastIndex() (index uint64, err error)

	// Write write the data into wal
	Write(data interface{}) error

	// Read read the data from wal
	Read(index uint64) (data []byte, err error)

	// TruncateFront truncate the data
	TruncateFront(index uint64) error

	// Close close the wal
	Close() error
}

Wal Service

type WalServiceImpl

type WalServiceImpl struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

WalServiceImpl

func NewWalService

func NewWalService(mf MarshalFunc, opFuncs ...ConsensusWalOptionFunc) (*WalServiceImpl, error)

NewWalService

func (*WalServiceImpl) Close

func (w *WalServiceImpl) Close() error

close

func (*WalServiceImpl) LastIndex

func (w *WalServiceImpl) LastIndex() (index uint64, err error)

Get LastIndex

func (*WalServiceImpl) Read

func (w *WalServiceImpl) Read(index uint64) (data []byte, err error)

Read read data from file, which is not supported in async mode

func (*WalServiceImpl) Sync

func (w *WalServiceImpl) Sync() error

Sync

func (*WalServiceImpl) TruncateFront

func (w *WalServiceImpl) TruncateFront(index uint64) error

Truncate Wal from index

func (*WalServiceImpl) WalMode

func (w *WalServiceImpl) WalMode() WalWriteMode

WalMode

func (*WalServiceImpl) Write

func (w *WalServiceImpl) Write(data interface{}) error

Wal Write

type WalWriteMode

type WalWriteMode int

WalWriteMode the mode of wal write

const (
	SyncWalWrite WalWriteMode = iota // write wal sync: 0
	AsyncWalWrite
	NonWalWrite
	WALWriteModeKey = "WAL_write_mode"
	WalDir          = "wal"
)

Jump to

Keyboard shortcuts

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