Documentation
¶
Index ¶
- Constants
- Variables
- func MakeVersionFile(prefix, suffix string, version uint64) string
- func MarshallEntrySize(size uint32) []byte
- func MarshallEntrySizeWithBuf(buf []byte, size uint32)
- func MarshallEntryType(typ EntryType) []byte
- func MarshallEntryTypeWithBuf(buf []byte, typ EntryType)
- func New(dir, name string, cfg *RotationCfg) (*store, error)
- func NewBatchStore(dir, name string, rotationCfg *RotationCfg) (*batchStore, error)
- func NewObservers(o1, o2 Observer) *observers
- func NewSimpleReplayer() *simpleReplayer
- func NewSyncAwareStore(dir, name string, rotationCfg *RotationCfg, syncerCfg *SyncerCfg) (*syncAwareStore, error)
- func ParseVersion(name, prefix, suffix string) (uint64, error)
- func UnmarshallEntrySize(buf []byte) uint32
- type AsyncBaseEntry
- type AsyncEntry
- type AwareStore
- type BaseEntry
- func (e *BaseEntry) Clone(o Entry)
- func (e *BaseEntry) Free()
- func (e *BaseEntry) GetAuxilaryInfo() interface{}
- func (e *BaseEntry) GetMeta() *EntryMeta
- func (e *BaseEntry) GetPayload() []byte
- func (e *BaseEntry) IsAsync() bool
- func (e *BaseEntry) Marshal() ([]byte, error)
- func (e *BaseEntry) ReadFrom(r io.Reader) (int64, error)
- func (e *BaseEntry) SetAuxilaryInfo(info interface{})
- func (e *BaseEntry) SetMeta(meta *EntryMeta)
- func (e *BaseEntry) Unmarshal(buf []byte) error
- func (e *BaseEntry) WriteTo(w StoreFileWriter, locker sync.Locker) (int64, error)
- type Entry
- type EntryHandler
- type EntryMeta
- func (meta *EntryMeta) GetReservedBuf() []byte
- func (meta *EntryMeta) GetType() EntryType
- func (meta *EntryMeta) IsCheckpoint() bool
- func (meta *EntryMeta) IsFlush() bool
- func (meta *EntryMeta) PayloadSize() uint32
- func (meta *EntryMeta) ReadFrom(r io.Reader) (int64, error)
- func (meta *EntryMeta) SetPayloadSize(size uint32)
- func (meta *EntryMeta) SetType(typ EntryType)
- func (meta *EntryMeta) Size() uint32
- func (meta *EntryMeta) String() string
- func (meta *EntryMeta) WriteTo(w io.Writer) (int64, error)
- type EntryType
- type HBHandleFactory
- type HistoryFactory
- type IHistory
- type IRotateChecker
- type MaxSizeRotationChecker
- type Observer
- type PostVersionDeleteCB
- type ReplayObserver
- type Replayer
- type RotationCfg
- type Rotational
- func (r *Rotational) ApplyCheckpoint(rng common.Range)
- func (r *Rotational) ApplyCommit(id uint64)
- func (r *Rotational) Close() error
- func (r *Rotational) GetHistory() IHistory
- func (r *Rotational) GetNextVersion() uint64
- func (r *Rotational) OnNewVersion(id uint64)
- func (r *Rotational) OnReplayCheckpoint(rng common.Range)
- func (r *Rotational) OnReplayCommit(id uint64)
- func (r *Rotational) PrepareWrite(size int) error
- func (r *Rotational) ReplayHistoryVersion(handler VersionReplayHandler) error
- func (r *Rotational) ReplayVersions(handler VersionReplayHandler) error
- func (r *Rotational) Stat() (os.FileInfo, error)
- func (r *Rotational) String() string
- func (r *Rotational) Sync() error
- func (r *Rotational) Truncate(size int64) error
- func (r *Rotational) TryCompact()
- func (r *Rotational) Write(buf []byte) (n int, err error)
- type Store
- type StoreFile
- type StoreFileWriter
- type SyncerCfg
- type VersionFile
- type VersionReplayHandler
Constants ¶
View Source
const (
DefaultVersionFileSize = 300 * int(common.M)
)
Variables ¶
View Source
var ( EntryTypeSize = int(unsafe.Sizeof(ETFlush)) EntrySizeSize = int(unsafe.Sizeof(uint32(0))) EntryReservedSize = int(unsafe.Sizeof(uint64(0))) * 8 EntryMetaSize = EntryTypeSize + EntrySizeSize + EntryReservedSize FlushEntry *BaseEntry )
View Source
var ( DefaultSuffix string = ".rot" DefaultRotationFileMaxSize = 100 * int(common.M) )
View Source
var ( DefaltHistoryFactory = func() IHistory { return &baseHistory{ versions: make([]*VersionFile, 0), } } )
View Source
var (
DefaultHBInterval = time.Duration(100) * time.Millisecond
)
View Source
var (
DefaultMaxBatchSize = 500
)
View Source
var (
ErrVersionNotFound = errors.New("aoe: version not found")
)
Functions ¶
func MakeVersionFile ¶
func MarshallEntrySize ¶
func MarshallEntryType ¶
func New ¶
func New(dir, name string, cfg *RotationCfg) (*store, error)
func NewBatchStore ¶
func NewBatchStore(dir, name string, rotationCfg *RotationCfg) (*batchStore, error)
func NewObservers ¶
func NewObservers(o1, o2 Observer) *observers
func NewSimpleReplayer ¶
func NewSimpleReplayer() *simpleReplayer
func NewSyncAwareStore ¶
func NewSyncAwareStore(dir, name string, rotationCfg *RotationCfg, syncerCfg *SyncerCfg) (*syncAwareStore, error)
func ParseVersion ¶
func UnmarshallEntrySize ¶
Types ¶
type AsyncBaseEntry ¶
type AsyncBaseEntry struct { BaseEntry // contains filtered or unexported fields }
func NewAsyncBaseEntry ¶
func NewAsyncBaseEntry() *AsyncBaseEntry
func (*AsyncBaseEntry) DoneWithErr ¶
func (e *AsyncBaseEntry) DoneWithErr(err error)
func (*AsyncBaseEntry) Free ¶
func (e *AsyncBaseEntry) Free()
func (*AsyncBaseEntry) GetError ¶
func (e *AsyncBaseEntry) GetError() error
func (*AsyncBaseEntry) IsAsync ¶
func (e *AsyncBaseEntry) IsAsync() bool
func (*AsyncBaseEntry) WaitDone ¶
func (e *AsyncBaseEntry) WaitDone() error
type AsyncEntry ¶
type AwareStore ¶
type BaseEntry ¶
type BaseEntry struct { Meta *EntryMeta Payload []byte Auxiliary interface{} // contains filtered or unexported fields }
func NewBaseEntryWithMeta ¶
func (*BaseEntry) GetAuxilaryInfo ¶
func (e *BaseEntry) GetAuxilaryInfo() interface{}
func (*BaseEntry) GetPayload ¶
func (*BaseEntry) SetAuxilaryInfo ¶
func (e *BaseEntry) SetAuxilaryInfo(info interface{})
type Entry ¶
type Entry interface { IsAsync() bool GetMeta() *EntryMeta SetMeta(*EntryMeta) GetPayload() []byte Unmarshal([]byte) error Marshal() ([]byte, error) ReadFrom(io.Reader) (int64, error) WriteTo(StoreFileWriter, sync.Locker) (int64, error) GetAuxilaryInfo() interface{} SetAuxilaryInfo(info interface{}) Free() }
type EntryMeta ¶
type EntryMeta struct {
Buf []byte
}
func NewEntryMeta ¶
func NewEntryMeta() *EntryMeta
func (*EntryMeta) GetReservedBuf ¶
func (*EntryMeta) IsCheckpoint ¶
func (*EntryMeta) PayloadSize ¶
func (*EntryMeta) SetPayloadSize ¶
type HBHandleFactory ¶
type HBHandleFactory = func(AwareStore) base.IHBHandle
type HistoryFactory ¶
type HistoryFactory func() IHistory
type IHistory ¶
type IHistory interface { String() string Append(*VersionFile) Extend([]*VersionFile) Versions() []uint64 VersionCnt() int Truncate(uint64) error Version(uint64) *VersionFile GetOldest() *VersionFile Empty() bool ReplayVersions(VersionReplayHandler, ReplayObserver) error }
type IRotateChecker ¶
type IRotateChecker interface {
PrepareAppend(*VersionFile, int64) (bool, error)
}
type MaxSizeRotationChecker ¶
type MaxSizeRotationChecker struct {
MaxSize int
}
func (*MaxSizeRotationChecker) PrepareAppend ¶
func (c *MaxSizeRotationChecker) PrepareAppend(f *VersionFile, delta int64) (bool, error)
type Observer ¶
type Observer interface { OnSynced() OnRotated(*VersionFile) }
type PostVersionDeleteCB ¶
type PostVersionDeleteCB = func(uint64)
type ReplayObserver ¶
type RotationCfg ¶
type RotationCfg struct { RotateChecker IRotateChecker Observer Observer HistoryFactory HistoryFactory }
type Rotational ¶
type Rotational struct { sync.RWMutex Dir string NamePrefix string NameSuffix string Checker IRotateChecker // contains filtered or unexported fields }
func OpenRotational ¶
func OpenRotational(dir, prefix, suffix string, historyFactory HistoryFactory, checker IRotateChecker, observer Observer) (*Rotational, error)
func (*Rotational) ApplyCheckpoint ¶
func (r *Rotational) ApplyCheckpoint(rng common.Range)
func (*Rotational) ApplyCommit ¶
func (r *Rotational) ApplyCommit(id uint64)
func (*Rotational) Close ¶
func (r *Rotational) Close() error
func (*Rotational) GetHistory ¶
func (r *Rotational) GetHistory() IHistory
func (*Rotational) GetNextVersion ¶
func (r *Rotational) GetNextVersion() uint64
func (*Rotational) OnNewVersion ¶
func (r *Rotational) OnNewVersion(id uint64)
func (*Rotational) OnReplayCheckpoint ¶
func (r *Rotational) OnReplayCheckpoint(rng common.Range)
func (*Rotational) OnReplayCommit ¶
func (r *Rotational) OnReplayCommit(id uint64)
func (*Rotational) PrepareWrite ¶
func (r *Rotational) PrepareWrite(size int) error
func (*Rotational) ReplayHistoryVersion ¶
func (r *Rotational) ReplayHistoryVersion(handler VersionReplayHandler) error
func (*Rotational) ReplayVersions ¶
func (r *Rotational) ReplayVersions(handler VersionReplayHandler) error
func (*Rotational) String ¶
func (r *Rotational) String() string
func (*Rotational) Sync ¶
func (r *Rotational) Sync() error
func (*Rotational) Truncate ¶
func (r *Rotational) Truncate(size int64) error
func (*Rotational) TryCompact ¶
func (r *Rotational) TryCompact()
type StoreFileWriter ¶
type SyncerCfg ¶
type SyncerCfg struct { Factory HBHandleFactory Interval time.Duration }
type VersionFile ¶
func (*VersionFile) Destroy ¶
func (vf *VersionFile) Destroy() error
func (*VersionFile) Truncate ¶
func (vf *VersionFile) Truncate(size int64) error
type VersionReplayHandler ¶
type VersionReplayHandler = func(*VersionFile, ReplayObserver) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.