wal_service

package
v2.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func DefaultMarshalFunc

func DefaultMarshalFunc(data interface{}) []byte

DefaultMarshalFunc default marshal func

Types

type ConsensusWalOption

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

ConsensusWalOption wal option struct

func NewDefaultConsensusWalOption

func NewDefaultConsensusWalOption() ConsensusWalOption

NewDefaultConsensusWalOption walWriteMode

type ConsensusWalOptionFunc

type ConsensusWalOptionFunc func(option *ConsensusWalOption)

ConsensusWalOptionFunc option func

func WithWriteMode

func WithWriteMode(walWriteMode WalWriteMode) ConsensusWalOptionFunc

WithWriteMode add WithWriteMode to option

func WithWritePath

func WithWritePath(walWritePath string) ConsensusWalOptionFunc

WithWritePath add walWritePath to option

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
}

WalOp Wal Operate

type WalOpType

type WalOpType int

WalOpType op type

const (
	// WalSyncOp sync op
	WalSyncOp WalOpType = iota
	// WalWriteOp write op
	WalWriteOp
	// WalTruncateOp truncate op
	WalTruncateOp
	// AsyncOpChanLength op chan length
	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
}

WalService Wal Service

type WalServiceImpl

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

WalServiceImpl struct

func NewWalService

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

NewWalService new service

func (*WalServiceImpl) Close

func (w *WalServiceImpl) Close() error

Close impl

func (*WalServiceImpl) LastIndex

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

LastIndex get last index

func (*WalServiceImpl) Read

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

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

func (*WalServiceImpl) Sync

func (w *WalServiceImpl) Sync() error

Sync sync

func (*WalServiceImpl) TruncateFront

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

TruncateFront Truncate Wal from index

func (*WalServiceImpl) WalMode

func (w *WalServiceImpl) WalMode() WalWriteMode

WalMode wal mode

func (*WalServiceImpl) Write

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

Write Wal Write

type WalWriteMode

type WalWriteMode int

WalWriteMode the mode of wal write

const (
	// SyncWalWrite sync wal write
	SyncWalWrite WalWriteMode = iota // write wal sync: 0
	// AsyncWalWrite async wal write
	AsyncWalWrite
	// NonWalWrite none wal write
	NonWalWrite
	// WALWriteModeKey mode key
	WALWriteModeKey = "WAL_write_mode"
	// WalDir wal dir
	WalDir = "wal"
)

Jump to

Keyboard shortcuts

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