Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultRetention = 1 * time.Hour DefaultCheckInterval = 10 * time.Minute )
Variables ¶
View Source
var ( ErrEntryNotFound = errors.New("oxia: entry not found") ErrOffsetOutOfBounds = errors.New("oxia: offset out of bounds") ErrReaderClosed = errors.New("oxia: reader already closed") ErrInvalidNextOffset = errors.New("oxia: invalid next offset in wal") InvalidTerm int64 = -1 InvalidOffset int64 = -1 )
View Source
var DefaultFactoryOptions = &FactoryOptions{ BaseWalDir: "data/wal", Retention: 1 * time.Hour, SegmentSize: 64 * 1024 * 1024, SyncData: true, }
Functions ¶
This section is empty.
Types ¶
type CommitOffsetProvider ¶
type CommitOffsetProvider interface {
CommitOffset() int64
}
type Factory ¶ added in v0.3.0
type Factory interface {
io.Closer
NewWal(namespace string, shard int64, provider CommitOffsetProvider) (Wal, error)
}
func NewWalFactory ¶
func NewWalFactory(options *FactoryOptions) Factory
type FactoryOptions ¶ added in v0.3.0
type ReadOnlySegment ¶
type ReadOnlySegmentsGroup ¶
type ReadWriteSegment ¶
type Reader ¶ added in v0.3.0
type Reader interface {
io.Closer
// ReadNext returns the next entry in the log according to the Reader's direction.
// If a forward/reverse WalReader has passed the end/beginning of the log, it returns [ErrorEntryNotFound].
// To avoid this error, use HasNext.
ReadNext() (*proto.LogEntry, error)
// HasNext returns true if there is an entry to read.
HasNext() bool
}
Reader reads the Wal sequentially. It is not synchronized itself.
type Wal ¶
type Wal interface {
io.Closer
// Append writes an entry to the end of the log.
// The wal is synced when Append returns
Append(entry *proto.LogEntry) error
// AppendAsync an entry without syncing the WAL
// Caller should use Sync to make the entry visible
AppendAsync(entry *proto.LogEntry) error
// Sync flushes all the entries in the wal to disk
Sync(ctx context.Context) error
// TruncateLog removes entries from the end of the log that have an ID greater than lastSafeEntry.
TruncateLog(lastSafeEntry int64) (int64, error)
// NewReader returns a new WalReader to traverse the log from the entry after `after` towards the log end
NewReader(after int64) (Reader, error)
// NewReverseReader returns a new WalReader to traverse the log from the last entry towards the beginning
NewReverseReader() (Reader, error)
// LastOffset Return the offset of the last entry committed to the WAL
// Return InvalidOffset if the WAL is empty
LastOffset() int64
// FirstOffset Return the offset of the first valid entry that is present in the WAL
// Return InvalidOffset if the WAL is empty
FirstOffset() int64
// Clear removes all the entries in the WAL
Clear() error
// Delete all the files and directories of the wal
Delete() error
}
Click to show internal directories.
Click to hide internal directories.