Documentation
¶
Index ¶
- type BadgerStorage
- func (bs *BadgerStorage) Backup(writer any) error
- func (bs *BadgerStorage) Compact() error
- func (bs *BadgerStorage) Delete(key []byte) error
- func (bs *BadgerStorage) Exists(key []byte) (bool, error)
- func (bs *BadgerStorage) Get(key []byte) ([]byte, error)
- func (bs *BadgerStorage) GetRange(start, end []byte) ([]internal.KeyValue, error)
- func (bs *BadgerStorage) Iterate(prefix []byte, fn func(key, value []byte) error) error
- func (bs *BadgerStorage) ListKeys(prefix []byte) ([][]byte, error)
- func (bs *BadgerStorage) RunGC(discardRatio float64) error
- func (bs *BadgerStorage) Set(key, value []byte) error
- func (bs *BadgerStorage) Size() (int64, error)
- func (bs *BadgerStorage) Start(ctx context.Context) error
- func (bs *BadgerStorage) Stop(ctx context.Context) error
- func (bs *BadgerStorage) WriteBatch(ops []internal.BatchOp) error
- type BadgerStorageConfig
- type BoltDBStorage
- func (bs *BoltDBStorage) Backup(path string) error
- func (bs *BoltDBStorage) Compact() error
- func (bs *BoltDBStorage) Delete(key []byte) error
- func (bs *BoltDBStorage) Exists(key []byte) (bool, error)
- func (bs *BoltDBStorage) Get(key []byte) ([]byte, error)
- func (bs *BoltDBStorage) GetRange(start, end []byte) ([]internal.KeyValue, error)
- func (bs *BoltDBStorage) Iterate(prefix []byte, fn func(key, value []byte) error) error
- func (bs *BoltDBStorage) ListKeys(prefix []byte) ([][]byte, error)
- func (bs *BoltDBStorage) Set(key, value []byte) error
- func (bs *BoltDBStorage) Size() (int64, error)
- func (bs *BoltDBStorage) Start(ctx context.Context) error
- func (bs *BoltDBStorage) Stats() map[string]any
- func (bs *BoltDBStorage) Stop(ctx context.Context) error
- func (bs *BoltDBStorage) WriteBatch(ops []internal.BatchOp) error
- type BoltDBStorageConfig
- type MemoryStorage
- func (s *MemoryStorage) Batch(ops []internal.BatchOp) error
- func (s *MemoryStorage) Clear() error
- func (s *MemoryStorage) Close() error
- func (s *MemoryStorage) Delete(key []byte) error
- func (s *MemoryStorage) Exists(key []byte) (bool, error)
- func (s *MemoryStorage) Get(key []byte) ([]byte, error)
- func (s *MemoryStorage) GetRange(start, end []byte) ([]internal.KeyValue, error)
- func (s *MemoryStorage) Iterate(prefix []byte, fn func(key, value []byte) error) error
- func (s *MemoryStorage) ListKeys(prefix []byte) ([][]byte, error)
- func (s *MemoryStorage) Set(key, value []byte) error
- func (s *MemoryStorage) Size() int
- func (s *MemoryStorage) Start(ctx context.Context) error
- func (s *MemoryStorage) Stop(ctx context.Context) error
- func (s *MemoryStorage) WriteBatch(ops []internal.BatchOp) error
- type MemoryStorageConfig
- type WAL
- func (w *WAL) Close() error
- func (w *WAL) GetStatistics() WALStatistics
- func (w *WAL) Read(ctx context.Context, startIndex uint64) ([]*WALEntry, error)
- func (w *WAL) Sync() error
- func (w *WAL) Truncate(ctx context.Context, index uint64) error
- func (w *WAL) Write(ctx context.Context, entry *WALEntry) error
- type WALConfig
- type WALEntry
- type WALEntryType
- type WALStatistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerStorage ¶
type BadgerStorage struct {
// contains filtered or unexported fields
}
BadgerStorage implements BadgerDB-based persistent storage.
func NewBadgerStorage ¶
func NewBadgerStorage(config BadgerStorageConfig, logger forge.Logger) (*BadgerStorage, error)
NewBadgerStorage creates a new BadgerDB storage.
func (*BadgerStorage) Backup ¶
func (bs *BadgerStorage) Backup(writer any) error
Backup creates a backup of the database.
func (*BadgerStorage) Compact ¶
func (bs *BadgerStorage) Compact() error
Compact triggers manual compaction.
func (*BadgerStorage) Delete ¶
func (bs *BadgerStorage) Delete(key []byte) error
Delete deletes a key.
func (*BadgerStorage) Exists ¶
func (bs *BadgerStorage) Exists(key []byte) (bool, error)
Exists checks if a key exists.
func (*BadgerStorage) Get ¶
func (bs *BadgerStorage) Get(key []byte) ([]byte, error)
Get retrieves a value by key.
func (*BadgerStorage) GetRange ¶
func (bs *BadgerStorage) GetRange(start, end []byte) ([]internal.KeyValue, error)
GetRange retrieves a range of key-value pairs.
func (*BadgerStorage) Iterate ¶
func (bs *BadgerStorage) Iterate(prefix []byte, fn func(key, value []byte) error) error
Iterate iterates over all key-value pairs with a given prefix.
func (*BadgerStorage) ListKeys ¶
func (bs *BadgerStorage) ListKeys(prefix []byte) ([][]byte, error)
ListKeys lists all keys with a given prefix.
func (*BadgerStorage) RunGC ¶
func (bs *BadgerStorage) RunGC(discardRatio float64) error
RunGC runs garbage collection.
func (*BadgerStorage) Set ¶
func (bs *BadgerStorage) Set(key, value []byte) error
Set stores a key-value pair.
func (*BadgerStorage) Size ¶
func (bs *BadgerStorage) Size() (int64, error)
Size returns the approximate size of the database in bytes.
func (*BadgerStorage) Start ¶
func (bs *BadgerStorage) Start(ctx context.Context) error
Start starts the storage backend.
func (*BadgerStorage) Stop ¶
func (bs *BadgerStorage) Stop(ctx context.Context) error
Stop stops the storage backend.
func (*BadgerStorage) WriteBatch ¶
func (bs *BadgerStorage) WriteBatch(ops []internal.BatchOp) error
WriteBatch writes a batch of operations atomically.
type BadgerStorageConfig ¶
type BadgerStorageConfig struct {
Path string
SyncWrites bool
ValueLogFileSize int64
NumVersionsToKeep int
NumCompactors int
MemTableSize int64
BaseTableSize int64
BloomFalsePositive float64
BlockSize int
BlockCacheSize int64
IndexCacheSize int64
NumLevelZeroTables int
NumLevelZeroStalls int
ValueThreshold int
NumMemtables int
DetectConflicts bool
CompactL0OnClose bool
}
BadgerStorageConfig contains BadgerDB storage configuration.
type BoltDBStorage ¶
type BoltDBStorage struct {
// contains filtered or unexported fields
}
BoltDBStorage implements BoltDB-based persistent storage.
func NewBoltDBStorage ¶
func NewBoltDBStorage(config BoltDBStorageConfig, logger forge.Logger) (*BoltDBStorage, error)
NewBoltDBStorage creates a new BoltDB storage.
func (*BoltDBStorage) Backup ¶
func (bs *BoltDBStorage) Backup(path string) error
Backup creates a backup of the database.
func (*BoltDBStorage) Compact ¶
func (bs *BoltDBStorage) Compact() error
Compact triggers manual compaction (BoltDB compacts automatically).
func (*BoltDBStorage) Delete ¶
func (bs *BoltDBStorage) Delete(key []byte) error
Delete deletes a key.
func (*BoltDBStorage) Exists ¶
func (bs *BoltDBStorage) Exists(key []byte) (bool, error)
Exists checks if a key exists.
func (*BoltDBStorage) Get ¶
func (bs *BoltDBStorage) Get(key []byte) ([]byte, error)
Get retrieves a value by key.
func (*BoltDBStorage) GetRange ¶
func (bs *BoltDBStorage) GetRange(start, end []byte) ([]internal.KeyValue, error)
GetRange retrieves a range of key-value pairs.
func (*BoltDBStorage) Iterate ¶
func (bs *BoltDBStorage) Iterate(prefix []byte, fn func(key, value []byte) error) error
Iterate iterates over all key-value pairs with a given prefix.
func (*BoltDBStorage) ListKeys ¶
func (bs *BoltDBStorage) ListKeys(prefix []byte) ([][]byte, error)
ListKeys lists all keys with a given prefix.
func (*BoltDBStorage) Set ¶
func (bs *BoltDBStorage) Set(key, value []byte) error
Set stores a key-value pair.
func (*BoltDBStorage) Size ¶
func (bs *BoltDBStorage) Size() (int64, error)
Size returns the size of the database in bytes.
func (*BoltDBStorage) Start ¶
func (bs *BoltDBStorage) Start(ctx context.Context) error
Start starts the storage backend.
func (*BoltDBStorage) Stats ¶
func (bs *BoltDBStorage) Stats() map[string]any
Stats returns database statistics.
func (*BoltDBStorage) Stop ¶
func (bs *BoltDBStorage) Stop(ctx context.Context) error
Stop stops the storage backend.
func (*BoltDBStorage) WriteBatch ¶
func (bs *BoltDBStorage) WriteBatch(ops []internal.BatchOp) error
WriteBatch writes a batch of operations atomically.
type BoltDBStorageConfig ¶
type BoltDBStorageConfig struct {
Path string
BucketName string
Timeout time.Duration
NoSync bool
NoGrowSync bool
ReadOnly bool
MmapFlags int
}
BoltDBStorageConfig contains BoltDB storage configuration.
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage implements an in-memory storage backend.
func NewMemoryStorage ¶
func NewMemoryStorage(config MemoryStorageConfig, logger forge.Logger) *MemoryStorage
NewMemoryStorage creates a new memory storage.
func (*MemoryStorage) Batch ¶
func (s *MemoryStorage) Batch(ops []internal.BatchOp) error
Batch executes a batch of operations.
func (*MemoryStorage) Close ¶
func (s *MemoryStorage) Close() error
Close closes the storage backend.
func (*MemoryStorage) Delete ¶
func (s *MemoryStorage) Delete(key []byte) error
Delete deletes a key.
func (*MemoryStorage) Exists ¶
func (s *MemoryStorage) Exists(key []byte) (bool, error)
Exists checks if a key exists.
func (*MemoryStorage) Get ¶
func (s *MemoryStorage) Get(key []byte) ([]byte, error)
Get retrieves a value by key.
func (*MemoryStorage) GetRange ¶
func (s *MemoryStorage) GetRange(start, end []byte) ([]internal.KeyValue, error)
GetRange retrieves a range of key-value pairs.
func (*MemoryStorage) Iterate ¶
func (s *MemoryStorage) Iterate(prefix []byte, fn func(key, value []byte) error) error
Iterate iterates over all key-value pairs.
func (*MemoryStorage) ListKeys ¶
func (s *MemoryStorage) ListKeys(prefix []byte) ([][]byte, error)
ListKeys lists all keys with a given prefix.
func (*MemoryStorage) Set ¶
func (s *MemoryStorage) Set(key, value []byte) error
Set stores a key-value pair.
func (*MemoryStorage) Size ¶
func (s *MemoryStorage) Size() int
Size returns the number of stored keys.
func (*MemoryStorage) Start ¶
func (s *MemoryStorage) Start(ctx context.Context) error
Start starts the storage backend.
func (*MemoryStorage) Stop ¶
func (s *MemoryStorage) Stop(ctx context.Context) error
Stop stops the storage backend.
func (*MemoryStorage) WriteBatch ¶
func (s *MemoryStorage) WriteBatch(ops []internal.BatchOp) error
WriteBatch writes a batch of operations atomically.
type MemoryStorageConfig ¶
type MemoryStorageConfig struct {
InitialCapacity int
}
MemoryStorageConfig contains configuration for memory storage.
type WAL ¶
type WAL struct {
// contains filtered or unexported fields
}
WAL implements Write-Ahead Logging for consensus operations.
func (*WAL) GetStatistics ¶
func (w *WAL) GetStatistics() WALStatistics
GetStatistics returns WAL statistics.
type WALConfig ¶
type WALConfig struct {
Dir string
MaxFileSize int64
SyncInterval time.Duration
EnableCompression bool
EnableChecksum bool
}
WALConfig contains WAL configuration.
type WALEntry ¶
type WALEntry struct {
Type WALEntryType
Index uint64
Term uint64
Data []byte
Timestamp time.Time
Checksum uint32
}
WALEntry represents a WAL entry.
type WALEntryType ¶
type WALEntryType uint8
WALEntryType represents the type of WAL entry.
const ( // WALEntryTypeLog log entry. WALEntryTypeLog WALEntryType = 1 // WALEntryTypeMeta metadata entry. WALEntryTypeMeta WALEntryType = 2 // WALEntryTypeSnapshot snapshot entry. WALEntryTypeSnapshot WALEntryType = 3 // WALEntryTypeCheckpoint checkpoint entry. WALEntryTypeCheckpoint WALEntryType = 4 )