Documentation ¶
Index ¶
- Variables
- func DefaultMarshalFunc(data interface{}) []byte
- type ConsensusWalOption
- type ConsensusWalOptionFunc
- type MarshalFunc
- type WalOp
- type WalOpType
- type WalService
- type WalServiceImpl
- func (w *WalServiceImpl) Close() error
- func (w *WalServiceImpl) LastIndex() (index uint64, err error)
- func (w *WalServiceImpl) Read(index uint64) (data []byte, err error)
- func (w *WalServiceImpl) Sync() error
- func (w *WalServiceImpl) TruncateFront(index uint64) error
- func (w *WalServiceImpl) WalMode() WalWriteMode
- func (w *WalServiceImpl) Write(data interface{}) error
- type WalWriteMode
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// UnSupportMarshalTypeFormat message
UnSupportMarshalTypeFormat = "it is not support to marshal for type[%T]"
)
Functions ¶
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 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 ¶
WalServiceImpl struct
func NewWalService ¶
func NewWalService(mf MarshalFunc, opFuncs ...ConsensusWalOptionFunc) (*WalServiceImpl, error)
NewWalService new service
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) TruncateFront ¶
func (w *WalServiceImpl) TruncateFront(index uint64) error
TruncateFront Truncate Wal from index
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" )
Click to show internal directories.
Click to hide internal directories.