Documentation ¶
Index ¶
- Constants
- Variables
- func ExistFile(filePath string) (ok bool)
- type Batch
- type Entry
- type EntryHeader
- func (header EntryHeader) Committed() (ok bool)
- func (header EntryHeader) Discarded() (ok bool)
- func (header EntryHeader) HashCode() (code uint64)
- func (header EntryHeader) Index() (index uint64)
- func (header EntryHeader) Removed() (ok bool)
- func (header EntryHeader) State() (state State)
- func (header EntryHeader) StateFinished() (ok bool)
- func (header EntryHeader) String() (s string)
- type File
- type KeyEncoder
- type Option
- type Options
- type SOT
- type State
- type TEU
- type TEUs
- type TransactionLevel
- type WAL
- func (wal *WAL[K]) Batch() (batch *Batch[K])
- func (wal *WAL[K]) Close()
- func (wal *WAL[K]) Commit(indexes ...uint64) (err error)
- func (wal *WAL[K]) CommitKey(keys ...K) (err error)
- func (wal *WAL[K]) CreateSnapshot(endIndex uint64, sink io.Writer) (err error)
- func (wal *WAL[K]) Discard(indexes ...uint64) (err error)
- func (wal *WAL[K]) DiscardKey(keys ...K) (err error)
- func (wal *WAL[K]) FirstIndex() (idx uint64, err error)
- func (wal *WAL[K]) FirstKey() (k K, err error)
- func (wal *WAL[K]) Key(key K) (index uint64, p []byte, state State, err error)
- func (wal *WAL[K]) LastIndex() (idx uint64, err error)
- func (wal *WAL[K]) LastKey() (k K, err error)
- func (wal *WAL[K]) Len() (n uint64)
- func (wal *WAL[K]) OldestUncommitted() (index uint64, has bool)
- func (wal *WAL[K]) OldestUncommittedKey() (key K, has bool)
- func (wal *WAL[K]) Read(index uint64) (key K, p []byte, state State, err error)
- func (wal *WAL[K]) Remove(index uint64) (err error)
- func (wal *WAL[K]) RemoveKey(key K) (err error)
- func (wal *WAL[K]) TruncateBack(startIndex uint64) (err error)
- func (wal *WAL[K]) TruncateFront(endIndex uint64) (err error)
- func (wal *WAL[K]) Uncommitted(index uint64) (ok bool)
- func (wal *WAL[K]) UncommittedKey(key K) (ok bool)
- func (wal *WAL[K]) UncommittedSize() (n uint64)
- func (wal *WAL[K]) Write(key K, p []byte) (index uint64, err error)
Constants ¶
View Source
const ( SOT64B = SOT(1 << (6 + iota)) SOT128B SOT256B SOT512B SOT1K SOT2K SOT4K SOT8K )
View Source
const ( UncommittedState = State(iota + 1) CommittedState DiscardedState )
View Source
const ( ReadCommitted = TransactionLevel(iota + 1) ReadUncommitted )
Variables ¶
View Source
var ( ErrInvalidEntry = fmt.Errorf("invalid entry") ErrClosed = fmt.Errorf("wal was closed") ErrNoFirstIndex = fmt.Errorf("wal has no first Index") ErrNoLastIndex = fmt.Errorf("wal has no last Index") ErrNotFound = fmt.Errorf("not found") ErrCommittedOrDiscarded = fmt.Errorf("entry was Committed or Discarded") )
Functions ¶
Types ¶
type Entry ¶
type Entry []byte
func DecodeEntries ¶
func (Entry) Header ¶ added in v1.4.0
func (entry Entry) Header() (header EntryHeader)
type EntryHeader ¶ added in v1.4.0
type EntryHeader []byte
func (EntryHeader) Committed ¶ added in v1.4.0
func (header EntryHeader) Committed() (ok bool)
func (EntryHeader) Discarded ¶ added in v1.4.0
func (header EntryHeader) Discarded() (ok bool)
func (EntryHeader) HashCode ¶ added in v1.4.0
func (header EntryHeader) HashCode() (code uint64)
func (EntryHeader) Index ¶ added in v1.4.0
func (header EntryHeader) Index() (index uint64)
func (EntryHeader) Removed ¶ added in v1.4.0
func (header EntryHeader) Removed() (ok bool)
func (EntryHeader) State ¶ added in v1.4.0
func (header EntryHeader) State() (state State)
func (EntryHeader) StateFinished ¶ added in v1.4.0
func (header EntryHeader) StateFinished() (ok bool)
func (EntryHeader) String ¶ added in v1.4.0
func (header EntryHeader) String() (s string)
type KeyEncoder ¶ added in v1.3.0
type KeyEncoder[K ordered] interface { Encode(key K) (p []byte, err error) Decode(p []byte) (key K, err error) }
func Int64KeyEncoder ¶ added in v1.3.0
func Int64KeyEncoder() KeyEncoder[int64]
func StringKeyEncoder ¶ added in v1.3.0
func StringKeyEncoder() KeyEncoder[string]
func Unit64KeyEncoder ¶ added in v1.3.0
func Unit64KeyEncoder() KeyEncoder[uint64]
type Option ¶ added in v1.3.2
type Option func(options *Options)
func EnableTransaction ¶ added in v1.3.2
func EnableTransaction(level TransactionLevel) Option
func WithCacheSize ¶ added in v1.3.2
type Options ¶ added in v1.3.2
type Options struct { SOT SOT CacheSize int TransactionEnabled bool TransactionLevel TransactionLevel }
type TransactionLevel ¶ added in v1.3.2
type TransactionLevel int
func (TransactionLevel) String ¶ added in v1.3.2
func (level TransactionLevel) String() string
type WAL ¶
type WAL[K ordered] struct {
// contains filtered or unexported fields
}
func New ¶
func New[K ordered](path string, keyEncoder KeyEncoder[K], options ...Option) (wal *WAL[K], err error)
func (*WAL[K]) CreateSnapshot ¶
CreateSnapshot contains end Index
func (*WAL[K]) DiscardKey ¶ added in v1.3.0
func (*WAL[K]) FirstIndex ¶
func (*WAL[K]) OldestUncommitted ¶
func (*WAL[K]) OldestUncommittedKey ¶ added in v1.3.2
func (*WAL[K]) TruncateBack ¶ added in v1.1.0
TruncateBack truncate logs after and contains startIndex
func (*WAL[K]) TruncateFront ¶ added in v1.1.0
TruncateFront truncate logs before and contains endIndex
func (*WAL[K]) Uncommitted ¶
func (*WAL[K]) UncommittedKey ¶ added in v1.3.1
func (*WAL[K]) UncommittedSize ¶ added in v1.2.0
Click to show internal directories.
Click to hide internal directories.