Versions in this module Expand all Collapse all v1 v1.0.0 Dec 4, 2022 Changes in this version + var ErrCodeSysType = errors.New("the coder type is system reservation type") + var ErrCoderExist = errors.New("this type coder has exist") + var ErrCoderNotExist = errors.New("this type coder not exist") + var ErrFileTypeNotSupport = errors.New("this file type is not supported") + var ErrPurgeNotReached = errors.New("purge threshold not reached") + var ErrPurgeWorkExisted = errors.New("purge work has been performed") + var ErrSegmentIndex = errors.New("index out of segment range") + var InitID = 1 + var InitIndex = 1 + var RawCoderType int8 = 0 + type Chansema struct + func NewChansema(n int) *Chansema + func (cs *Chansema) Acquire(ctx context.Context) error + func (cs *Chansema) Release() + func (cs *Chansema) TryAcquire() bool + type Coder interface + Decode func([]byte) (interface{}, error) + Encode func(interface{}) ([]byte, error) + Type func() int8 + type EntryContainer interface + FirstIndex func() uint64 + GetCoder func(int8) (Coder, error) + GetLogEntry func(idx uint64) (*LogEntry, error) + LastIndex func() uint64 + ReaderRelease func() + type EntryElemnet struct + func (ele *EntryElemnet) Get() ([]byte, error) + func (ele *EntryElemnet) GetObj() (interface{}, error) + func (ele *EntryElemnet) Index() uint64 + type EntryIterator struct + func (it *EntryIterator) HasNext() bool + func (it *EntryIterator) HasNextN(n int) bool + func (it *EntryIterator) HasPre() bool + func (it *EntryIterator) HasPreN(n int) bool + func (it *EntryIterator) Next() *EntryElemnet + func (it *EntryIterator) NextN(n int) *EntryElemnet + func (it *EntryIterator) Previous() *EntryElemnet + func (it *EntryIterator) PreviousN(n int) *EntryElemnet + func (it *EntryIterator) Release() + func (it *EntryIterator) SkipToFirst() + func (it *EntryIterator) SkipToLast() + type FileLock struct + func NewFileLocker(path string) *FileLock + func (fl *FileLock) Lock() error + func (fl *FileLock) Unlock() error + type FileType int + const FT_MMAP + const FT_NORMAL + type FlushStrategy int + type LogEntry struct + Crc32 uint32 + Data []byte + Len int + Typ int8 + type Lws struct + func Open(path string, opt ...Opt) (*Lws, error) + func OpenWithDSL(sl *dsl.DSL, opt ...Opt) (*Lws, error) + func (l *Lws) Close() + func (l *Lws) Flush() error + func (l *Lws) NewLogIterator() *EntryIterator + func (l *Lws) Purge(opt ...PurgeOpt) error + func (l *Lws) ReadFromFile(file string) (*EntryIterator, error) + func (l *Lws) RegisterCoder(c Coder) error + func (l *Lws) UnregisterCoder(t int8) error + func (l *Lws) Write(typ int8, obj interface{}) error + func (l *Lws) WriteBytes(data []byte) (uint64, error) + func (l *Lws) WriteRetIndex(typ int8, obj interface{}) (uint64, error) + func (l *Lws) WriteToFile(file string, typ int8, obj interface{}) error + type LwsFile interface + Close func() error + ReadAt func([]byte, int64) (int, error) + Size func() int64 + Sync func() error + Truncate func(int64) error + WriteAt func([]byte, int64) (int, error) + type Opt func(*Options) + func WithBufferSize(s int) Opt + func WithEntryLimitForPurge(l int) Opt + func WithFileExtension(ext string) Opt + func WithFileLimitForPurge(l int) Opt + func WithFilePrex(prex string) Opt + func WithMmapFileLock() Opt + func WithSegmentSize(s int64) Opt + func WithWriteFileType(ft FileType) Opt + func WithWriteFlag(wf WriteFlag, quota int) Opt + type Options struct + BufferSize int + FileExtension string + FilePrefix string + FlushQuota int + Ft FileType + LogEntryCountLimitForPurge int + LogFileLimitForPurge int + MmapFileLock bool + SegmentSize int64 + Wf WriteFlag + type PurgeOpt func(*PurgeOptions) + func PurgeWithAsync() PurgeOpt + func PurgeWithKeepFiles(c int) PurgeOpt + func PurgeWithSoftEntries(c int) PurgeOpt + type PurgeOptions struct + type ReaderCache struct + func (rc *ReaderCache) CleanReader() + func (rc *ReaderCache) DeleteReader(segmentID uint64) *refReader + func (rc *ReaderCache) GetAndNewReader(segmentID uint64, new func() (*refReader, error)) (*refReader, error) + func (rc *ReaderCache) GetReader(segmentID uint64) *refReader + func (rc *ReaderCache) PutReader(segmentID uint64, rr *refReader) + type Segment struct + ID uint64 + Index uint64 + Path string + Size int64 + type SegmentGroup []*Segment + func (sg *SegmentGroup) Append(s *Segment) + func (sg *SegmentGroup) Assign(i int, s *Segment) + func (sg *SegmentGroup) At(i int) *Segment + func (sg *SegmentGroup) Cap() int + func (sg *SegmentGroup) FindAt(idx uint64) *Segment + func (sg *SegmentGroup) First() *Segment + func (sg *SegmentGroup) ForEach(fn func(i int, s *Segment) bool) + func (sg *SegmentGroup) Last() *Segment + func (sg *SegmentGroup) Len() int + func (sg *SegmentGroup) Reserved(n int) + func (sg *SegmentGroup) Resize(n int) + func (sg *SegmentGroup) Split(i int) (SegmentGroup, SegmentGroup) + type SegmentProcessor struct + func (sp *SegmentProcessor) Close() error + type SegmentReader struct + func NewSegmentReader(s *Segment, ft FileType) (*SegmentReader, error) + func (sr *SegmentReader) FirstIndex() uint64 + func (sr *SegmentReader) LastIndex() uint64 + func (sr *SegmentReader) ReadLogByIndex(index uint64) (*LogEntry, error) + type SegmentWriter struct + func NewSegmentWriter(s *Segment, opt WriterOptions) (*SegmentWriter, error) + func (sw *SegmentWriter) Close() error + func (sw *SegmentWriter) EntryCount() int + func (sw *SegmentWriter) Flush() error + func (sw *SegmentWriter) Replace(s *Segment) error + func (sw *SegmentWriter) Size() int64 + func (sw *SegmentWriter) Write(t int8, data []byte) (int, error) + type WriteFlag int + const WF_QUOTAFLUSH + const WF_SYNCFLUSH + const WF_SYNCWRITE + const WF_TIMEDFLUSH + type WriterOptions struct + BufferSize int + Ft FileType + Fv int + MapLock bool + SegmentSize int64 + Wf WriteFlag