Documentation
¶
Index ¶
- Constants
- type ReplayCallbackFunc
- type WALBackendsConfigs
- type XWAL
- func (wal *XWAL) Close() error
- func (wal *XWAL) CreateCheckpoint() (uint64, error)
- func (wal *XWAL) IsClosed() bool
- func (wal *XWAL) PeriodicFlush()
- func (wal *XWAL) Replay(callback ReplayCallbackFunc, batchSize int, backwards bool) error
- func (wal *XWAL) ReplayFromCheckpoint(callback ReplayCallbackFunc, checkpoint uint64, backwards bool) error
- func (wal *XWAL) ReplayFromRange(callback ReplayCallbackFunc, batchSize int, backwards bool, start, end uint32) error
- func (wal *XWAL) ReplayToCheckpoint(callback ReplayCallbackFunc, checkpoint uint64, backwards bool) error
- func (wal *XWAL) Write(data []byte) error
- func (wal *XWAL) WriteBatch(entries []*xwalpb.WALEntry) error
- type XWALConfig
- type XWALError
- type XWALErrorTypes
Constants ¶
const ( // BadConfiguration is returned when the configuration passed to xWAL is invalid. XWALBadConfiguration = iota // DirectoryNotFound is returned when the directory specified in the configuration does not exist. XWALDirectoryNotFound // InvalidBufferSize is returned when the buffer size specified in the configuration is invalid. XWALInvalidBufferSize // InvalidFlushFrequency is returned when the flush frequency specified in the configuration is invalid. XWALInvalidFlushFrequency // InvalidSegmentSize is returned when the segment size specified in the configuration is invalid. XWALInvalidSegmentSize // InvalidFileSize is returned when the file size specified in the configuration is invalid. XWALInvalidFileSize )
const (
XWALConfigDefaultFile = "xwal.yaml"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReplayCallbackFunc ¶
The replay callback function signature
type WALBackendsConfigs ¶
type WALBackendsConfigs struct {
LocalFS *localfs.LocalFSConfig `yaml:"localfs,omitempty"`
}
type XWAL ¶
type XWAL struct {
// Ticker to control the flush frequency
FlushInterval *time.Ticker
// contains filtered or unexported fields
}
XWAL is the main struct that implements the WAL and control the lifecycle of the WAL. It is responsible to control the WAL Backend
func NewXWAL ¶
func NewXWAL(cfg *XWALConfig) (*XWAL, error)
func (*XWAL) CreateCheckpoint ¶ added in v0.1.0
CreateCheckpoint creates a checkpoint on the WAL. Checkpoints are simply suffixes on the segments files. Checkpoints will be used for Replaying the WAL from or to a given checkpoint. The method returns the checkpoint segments file number so the user can store it for later replay from that particular checkpoint further.
func (*XWAL) PeriodicFlush ¶
func (wal *XWAL) PeriodicFlush()
func (*XWAL) Replay ¶
func (wal *XWAL) Replay(callback ReplayCallbackFunc, batchSize int, backwards bool) error
func (*XWAL) ReplayFromCheckpoint ¶ added in v0.1.0
func (wal *XWAL) ReplayFromCheckpoint(callback ReplayCallbackFunc, checkpoint uint64, backwards bool) error
ReplayFromCheckpoint replays the WAL FROM a given checkpoint til the END of the WAL. It can be replayed backwards: from the end of the WAL til the given checkpoint. Entries read from the WAL Backend will be processed by the provided callback function.
func (*XWAL) ReplayFromRange ¶
func (*XWAL) ReplayToCheckpoint ¶ added in v0.1.0
func (wal *XWAL) ReplayToCheckpoint(callback ReplayCallbackFunc, checkpoint uint64, backwards bool) error
ReplayToCheckpoint replays the WAL from the BEGINNING of the WAL til the given checkpoint. It can be replayed backwards: from the given checkpoint til the beginning of the WAL. Entries read from the WAL Backend will be processed by the provided callback function.
type XWALConfig ¶
type XWALConfig struct {
// Path to the yaml configuration file
ConfigFile string
// Type of the WAL Backend to be used
WALBackend types.WALBackendType `yaml:"walBackend"`
// The backend configuration
BackendConfig WALBackendsConfigs `yaml:"backends"`
// Size of the in memory buffer in MB
BufferSize float64 `yaml:"bufferSize"`
// Number of entries allowed inside the in memory buffer
BufferEntriesLength int `yaml:"bufferEntriesLength"`
// Frequency that xWAL Flushes data from memory to target WAL Backend
FlushFrequency time.Duration `yaml:"flushFrequency"`
// Defines which log level should xWAL use (debug, info, warn, error)
LogLevel string `yaml:"logLevel"`
}
The configuration of the xWAL. It will drive how the xWAL will use any WAL Backend implementation
func NewXWALConfig ¶
func NewXWALConfig(filename string) *XWALConfig
Creates a new XWALConfig from yaml file or default values
type XWALError ¶
type XWALError struct {
// Type is the type of error that occurred.
Type XWALErrorTypes
// Message is a human-readable message that describes the error.
Message string
// Context is a map of key-value pairs that provide additional context for the error.
Context map[string]string
}
XWALError is a custom error type that is returned by the xwal package.
func NewXWALError ¶
func NewXWALError(t XWALErrorTypes, m string, c map[string]string) *XWALError
NewXWALError creates a new XWALError with the specified type, message, and context.
type XWALErrorTypes ¶
type XWALErrorTypes uint8
XWALErrorTypes is an enum for the different types of errors that can be returned by the xwal package.