Documentation ¶
Index ¶
- Constants
- func GenUUID() (string, error)
- func IsDir(filename string) bool
- func IsFile(filename string) bool
- func SetLogger(l Logger)
- func ToAbs(p string) (string, error)
- type BinLog
- func (l *BinLog) AppendEntry(f File, pos int64, entry *LogEntry) (int64, error)
- func (l *BinLog) IsValidFile(f File) (bool, error)
- func (l *BinLog) ReadEntry(f File, pos int64, entry *LogEntry) (int64, error)
- func (l *BinLog) ReadHeader(f File) (*FileHeader, error)
- func (l *BinLog) WriteHeader(f File, header *FileHeader) error
- type ChangeCount
- type DBRecord
- type File
- type Iterator
- type JsonLog
- func (l *JsonLog) AppendEntry(f File, pos int64, entry *LogEntry) (int64, error)
- func (l *JsonLog) IsValidFile(f File) (bool, error)
- func (l *JsonLog) ReadEntry(f File, pos int64, entry *LogEntry) (int64, error)
- func (l *JsonLog) ReadHeader(f File) (*FileHeader, error)
- func (l *JsonLog) WriteHeader(f File, header *FileHeader) error
- type LogFormat
- type LogInput
- type LogProgress
- type LogProgressMgr
- type LogRunner
- type Logger
- type NetworkInfo
- type NodeStorage
- type NodeStorageImpl
- func (n *NodeStorageImpl) Add(record *DBRecord) error
- func (n *NodeStorageImpl) AllNodes() ([]*DBRecord, error)
- func (n *NodeStorageImpl) GetByGid(gid string) (*DBRecord, error)
- func (n *NodeStorageImpl) GetByKey(key string) ([]*DBRecord, error)
- func (n *NodeStorageImpl) Init()
- func (n *NodeStorageImpl) Merge(other ReadOnlyNodeStorage) error
- func (n *NodeStorageImpl) Replace(old string, new *DBRecord) error
- type Participant
- func (p *Participant) Accept(v *Value, seq int) error
- func (p *Participant) All() ([]*Value, error)
- func (p *Participant) AllConflicts() ([]*Value, error)
- func (p *Participant) Close()
- func (p *Participant) Del(key string) error
- func (p *Participant) Has(key string) (bool, error)
- func (p *Participant) Init(wd string, machineID string) (err error)
- func (p *Participant) Load(key string) (*Value, error)
- func (p *Participant) Save(key string, value string) error
- type ParticipantInfo
- type ReadOnlyNodeStorage
- type RunLogContext
- type RunLogError
- type RunLogResult
- type RunLogWorker
- type SqliteAdapter
- func (s *SqliteAdapter) Add(record *DBRecord) error
- func (s *SqliteAdapter) AllNodes() ([]*DBRecord, error)
- func (s *SqliteAdapter) Close() error
- func (s *SqliteAdapter) GetByGid(gid string) (*DBRecord, error)
- func (s *SqliteAdapter) GetByKey(key string) ([]*DBRecord, error)
- func (s *SqliteAdapter) Has(gid string) (bool, error)
- func (s *SqliteAdapter) Init(dbFile string) error
- func (s *SqliteAdapter) Merge(other ReadOnlyNodeStorage) error
- func (s *SqliteAdapter) Processes() ([]*LogProgress, error)
- func (s *SqliteAdapter) Replace(old string, new *DBRecord) error
- func (s *SqliteAdapter) Transaction(f func(s *SqliteAdapter) error) error
- type Storage
- type Value
- type ValueVersion
- type Wal
- func (w *Wal) Append(logOp ...*LogOperation) (string, int64, error)
- func (w *Wal) AppendRaw(logOp ...*LogOperation) error
- func (w *Wal) Close() error
- func (w *Wal) Flush() error
- func (w *Wal) Init(filename string, l LogFormat, readonly bool) (err error)
- func (w *Wal) Iterator() *WalIterator
- func (w *Wal) IteratorFrom(start string, inclusive bool) (*WalIterator, error)
- func (w *Wal) IteratorOffset(offset int64) *WalIterator
- func (w *Wal) Offset() int64
- func (w *Wal) RangeIterator(start string, end string, includeStart bool, includeEnd bool) (*WalIterator, error)
- type WalHelper
- type WalIterator
Constants ¶
View Source
const ( Silent = iota Error Warn Info )
View Source
const DBFileName = "0.db"
View Source
const HeaderSize = 0x100
View Source
const SyncInterval = time.Minute
View Source
const WalFileName = "0.wal"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinLog ¶
type BinLog struct { }
func (*BinLog) AppendEntry ¶
写失败将破坏文件数据
func (*BinLog) ReadHeader ¶
func (*BinLog) WriteHeader ¶
写失败将破坏文件数据
type ChangeCount ¶
func (*ChangeCount) Scan ¶
func (n *ChangeCount) Scan(value any) error
Scan implements the Scanner interface.
type DBRecord ¶
type DBRecord struct { Key string `gorm:"index;column:key"` Value string `gorm:"column:value"` MachineID string `gorm:"column:machine_id"` Offset int64 `gorm:"column:offset"` PrevMachineID string `gorm:"column:prev_machine_id"` Seq uint64 `gorm:"column:seq"` CurrentLogGid string `gorm:"uniqueIndex;column:gid"` PrevLogGid string `gorm:"column:prev_log_gid"` IsDiscarded bool `gorm:"column:is_discarded"` IsDeleted bool `gorm:"column:is_deleted"` MachineChangeCount ChangeCount `gorm:"column:change_count"` Num int64 `gorm:"num"` PrevNum int64 `gorm:"prev_num"` CreatedAt time.Time UpdatedAt time.Time DeletedAt sql.NullTime `gorm:"index"` }
is_deleted || is_discarded can be removed from storage any time
type JsonLog ¶
type JsonLog struct { }
func (*JsonLog) AppendEntry ¶
写失败将破坏文件数据
func (*JsonLog) ReadHeader ¶
func (*JsonLog) WriteHeader ¶
写失败将破坏文件数据
type LogProgress ¶
type LogProgress struct { Offset int64 `gorm:"column:offset"` // HeaderSize should be used as initial value Num int64 `gorm:"column:num"` Gid string `gorm:"column:gid"` MachineID string `gorm:"uniqueIndex;column:machine_id"` CreatedAt time.Time UpdatedAt time.Time DeletedAt sql.NullTime `gorm:"index"` }
call newLogProgress to make instance
type LogProgressMgr ¶
type LogProgressMgr struct {
// contains filtered or unexported fields
}
func (*LogProgressMgr) Get ¶
func (m *LogProgressMgr) Get(machineID string) *LogProgress
func (*LogProgressMgr) Init ¶
func (m *LogProgressMgr) Init(progress ...*LogProgress)
func (*LogProgressMgr) Set ¶
func (m *LogProgressMgr) Set(machineID string, progress *LogProgress)
type NetworkInfo ¶
type NetworkInfo struct {
// contains filtered or unexported fields
}
func (*NetworkInfo) Add ¶
func (n *NetworkInfo) Add(name string) *ParticipantInfo
func (*NetworkInfo) Init ¶
func (n *NetworkInfo) Init(wd string) error
type NodeStorage ¶
type NodeStorage interface { ReadOnlyNodeStorage Add(record *DBRecord) error Replace(old string, new *DBRecord) error Merge(other ReadOnlyNodeStorage) error }
type NodeStorageImpl ¶
type NodeStorageImpl struct {
// contains filtered or unexported fields
}
func (*NodeStorageImpl) Add ¶
func (n *NodeStorageImpl) Add(record *DBRecord) error
func (*NodeStorageImpl) AllNodes ¶
func (n *NodeStorageImpl) AllNodes() ([]*DBRecord, error)
func (*NodeStorageImpl) GetByGid ¶
func (n *NodeStorageImpl) GetByGid(gid string) (*DBRecord, error)
func (*NodeStorageImpl) GetByKey ¶
func (n *NodeStorageImpl) GetByKey(key string) ([]*DBRecord, error)
func (*NodeStorageImpl) Init ¶
func (n *NodeStorageImpl) Init()
func (*NodeStorageImpl) Merge ¶
func (n *NodeStorageImpl) Merge(other ReadOnlyNodeStorage) error
type Participant ¶
type Participant struct {
// contains filtered or unexported fields
}
Participant ...
func (*Participant) All ¶
func (p *Participant) All() ([]*Value, error)
func (*Participant) AllConflicts ¶
func (p *Participant) AllConflicts() ([]*Value, error)
func (*Participant) Close ¶
func (p *Participant) Close()
func (*Participant) Del ¶
func (p *Participant) Del(key string) error
type ParticipantInfo ¶
type ParticipantInfo struct {
// contains filtered or unexported fields
}
func (*ParticipantInfo) Init ¶
func (p *ParticipantInfo) Init(wd string, name string, n *NetworkInfo)
type ReadOnlyNodeStorage ¶
type RunLogContext ¶
type RunLogContext struct {
// contains filtered or unexported fields
}
func (*RunLogContext) Init ¶
func (c *RunLogContext) Init(i ...*LogInput)
func (*RunLogContext) Progress ¶
func (c *RunLogContext) Progress(machineID string) *LogProgress
type RunLogError ¶
type RunLogError struct {
// contains filtered or unexported fields
}
func (*RunLogError) Error ¶
func (e *RunLogError) Error() string
type RunLogResult ¶
type RunLogResult struct {
// contains filtered or unexported fields
}
func (*RunLogResult) Error ¶
func (r *RunLogResult) Error() error
func (*RunLogResult) Init ¶
func (r *RunLogResult) Init(s map[string]*LogProgress, e *RunLogError)
func (*RunLogResult) Process ¶
func (r *RunLogResult) Process(machineID string) *LogProgress
type RunLogWorker ¶
type RunLogWorker struct {
// contains filtered or unexported fields
}
type SqliteAdapter ¶
type SqliteAdapter struct {
// contains filtered or unexported fields
}
SqliteAdapter ...
func (*SqliteAdapter) Add ¶
func (s *SqliteAdapter) Add(record *DBRecord) error
func (*SqliteAdapter) AllNodes ¶
func (s *SqliteAdapter) AllNodes() ([]*DBRecord, error)
func (*SqliteAdapter) Close ¶
func (s *SqliteAdapter) Close() error
func (*SqliteAdapter) Init ¶
func (s *SqliteAdapter) Init(dbFile string) error
func (*SqliteAdapter) Merge ¶
func (s *SqliteAdapter) Merge(other ReadOnlyNodeStorage) error
func (*SqliteAdapter) Processes ¶
func (s *SqliteAdapter) Processes() ([]*LogProgress, error)
func (*SqliteAdapter) Transaction ¶
func (s *SqliteAdapter) Transaction(f func(s *SqliteAdapter) error) error
type Storage ¶
type Storage interface { Save(key string, value string) error Del(key string) error Has(key string) (bool, error) Load(key string) (val *Value, err error) All() ([]*Value, error) Accept(v *Value, seq int) error }
Storage ...
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
func (*Value) Branches ¶
func (v *Value) Branches() []*ValueVersion
func (*Value) Main ¶
func (v *Value) Main() *ValueVersion
func (*Value) Versions ¶
func (v *Value) Versions() []*ValueVersion
type ValueVersion ¶
type ValueVersion struct {
// contains filtered or unexported fields
}
func (*ValueVersion) String ¶
func (v *ValueVersion) String() string
type Wal ¶
type Wal struct {
// contains filtered or unexported fields
}
func (*Wal) Append ¶
Append multiple operations will be appended as a single log entry returns the gid of the last operation generate and populate .Num, .Gid for each operation
func (*Wal) Iterator ¶
func (w *Wal) Iterator() *WalIterator
func (*Wal) IteratorFrom ¶
func (w *Wal) IteratorFrom(start string, inclusive bool) (*WalIterator, error)
func (*Wal) IteratorOffset ¶
func (w *Wal) IteratorOffset(offset int64) *WalIterator
func (*Wal) RangeIterator ¶
type WalHelper ¶
type WalHelper struct {
// contains filtered or unexported fields
}
type WalIterator ¶
type WalIterator struct {
// contains filtered or unexported fields
}
func (*WalIterator) Init ¶
func (i *WalIterator) Init(w *Wal)
func (*WalIterator) InitWithOffset ¶
func (i *WalIterator) InitWithOffset(w *Wal, offset int64)
func (*WalIterator) LogOp ¶
func (i *WalIterator) LogOp() *LogOperation
func (*WalIterator) Next ¶
func (i *WalIterator) Next() (hasNext bool)
func (*WalIterator) Offset ¶
func (i *WalIterator) Offset() int64
Click to show internal directories.
Click to hide internal directories.