Versions in this module Expand all Collapse all v0 v0.2.1 Dec 5, 2024 v0.2.0 Oct 18, 2024 Changes in this version type Store + func (s *Store) EnforceL0Retention(ctx context.Context, tx *sql.Tx, db *DB, maxTXID ltx.TXID, ts time.Time) error + func (s *Store) WithTestTx(t testing.TB, fn func(*sql.Tx)) v0.1.8 Oct 17, 2024 Changes in this version type Store + func (s *Store) ProcessCompaction(ctx context.Context, req *CompactionRequest, logger *slog.Logger) error v0.1.6 Oct 17, 2024 Changes in this version + const CompactionLevelRestoreTarget + const MaxCompactionFileN + const SQLITE_DATABASE_HEADER_SIZE + const SQLITE_DATABASE_HEADER_STRING + var ErrStopIter = errors.New("stop iter") + func AttachMetadata(ctx context.Context, client StorageClient, paths []StoragePath, ...) error + func CompareStoragePath(a, b *StoragePath) int + func ForEachStorageCluster(ctx context.Context, client StorageClient, fn func(cluster string) error) error + func ForEachStorageDatabase(ctx context.Context, client StorageClient, ...) error + func FormatStorageLevelDir(cluster, database string, level int, sep rune) (_ string, retErr error) + func FormatStoragePath(p StoragePath, sep rune) (_ string, retErr error) + func NewCompactorFromPaths(ctx context.Context, client StorageClient, paths []StoragePath, w io.Writer) (c *ltx.Compactor, close func() error, retErr error) + func StorageTXIDRange(ctx context.Context, client StorageClient, cluster, database string, level int) (min, max ltx.TXID, err error) + type ChangeSet map[uint32]struct + func NewChangeSetFromPaths(ctx context.Context, client StorageClient, paths []StoragePath) (ChangeSet, error) + func (c ChangeSet) Add(pgno uint32) + func (c ChangeSet) AsSlice() []uint32 + type CompactionLevel struct + Interval time.Duration + Level int + Retention time.Duration + func (lvl *CompactionLevel) NextCompactionAt(now time.Time) time.Time + type CompactionLevels []*CompactionLevel + func (a CompactionLevels) IsValidLevel(level int) bool + func (a CompactionLevels) MaxLevel() int + func (a CompactionLevels) NextLevel(level int) int + func (a CompactionLevels) PrevLevel(level int) int + func (a CompactionLevels) Validate() error + type CompactionRequest struct + Cluster string + Database string + IdempotencyKey int + Level int + type DB struct + Cluster string + Commit uint32 + HWM ltx.TXID + ID int + Name string + PageSize uint32 + PostApplyChecksum ltx.Checksum + TXID ltx.TXID + Timestamp time.Time + func (db *DB) Pos() ltx.Pos + type DBInfo struct + Name string + RestorablePaths []StoragePath + type DBTX interface + ExecContext func(context.Context, string, ...interface{}) (sql.Result, error) + PrepareContext func(context.Context, string) (*sql.Stmt, error) + QueryContext func(context.Context, string, ...interface{}) (*sql.Rows, error) + QueryRowContext func(context.Context, string, ...interface{}) *sql.Row + type Page struct + Chksum uint64 + DBID int + Data []byte + MaxTXID ltx.TXID + MinTXID ltx.TXID + Nonce []byte + Pgno uint32 + Tag []byte + type StorageClient interface + Clusters func(ctx context.Context) ([]string, error) + Databases func(ctx context.Context, cluster string) ([]string, error) + DeleteFiles func(ctx context.Context, paths []StoragePath) error + Iterator func(ctx context.Context, cluster, db string, level int) (StoragePathIterator, error) + Levels func(ctx context.Context, cluster, database string) ([]int, error) + Metadata func(ctx context.Context, path StoragePath) (StorageMetadata, error) + OpenFile func(ctx context.Context, path StoragePath) (io.ReadCloser, error) + WriteFile func(ctx context.Context, path StoragePath, r io.Reader) error + type StorageMetadata struct + Commit uint32 + PageSize uint32 + PostApplyChecksum ltx.Checksum + PreApplyChecksum ltx.Checksum + Timestamp time.Time + func NewStorageMetadataFromLTX(header ltx.Header, trailer ltx.Trailer) StorageMetadata + func (m StorageMetadata) IsZero() bool + type StoragePath struct + Cluster string + CreatedAt time.Time + Database string + Level int + MaxTXID ltx.TXID + Metadata StorageMetadata + MinTXID ltx.TXID + Size int64 + func CalcChangesPlan(ctx context.Context, client StorageClient, cluster, database string, ...) ([]StoragePath, error) + func CalcSnapshotPlan(ctx context.Context, client StorageClient, cluster, database string, ...) ([]StoragePath, error) + func FindStoragePaths(ctx context.Context, client StorageClient, cluster, database string, level int, ...) ([]StoragePath, error) + func MaxStoragePath(ctx context.Context, client StorageClient, cluster, database string, level int) (StoragePath, error) + func NewStoragePath(cluster, database string, level int, minTXID, maxTXID ltx.TXID) StoragePath + func (p *StoragePath) Validate() error + func (p StoragePath) Equal(other StoragePath) bool + func (p StoragePath) IsZero() bool + func (p StoragePath) String() string + type StoragePathIterator interface + NextStoragePath func(ctx context.Context) (StoragePath, error) + type StoragePathSlice []StoragePath + func (a StoragePathSlice) MaxTXID() ltx.TXID + type StoragePathSliceIterator struct + func NewStoragePathSliceIterator(a []StoragePath) *StoragePathSliceIterator + func (itr *StoragePathSliceIterator) Close() error + func (itr *StoragePathSliceIterator) NextStoragePath(ctx context.Context) (StoragePath, error) + type Store struct + CompactionEnabled bool + Levels CompactionLevels + Now func() time.Time + RemoteClient StorageClient + SnapshotInterval time.Duration + func NewStore(config *lfsb.Config) *Store + func (s *Store) CompactDBToLevel(ctx context.Context, callerTx *sql.Tx, cluster, database string, dstLevel int) (StoragePath, error) + func (s *Store) DeleteCluster(ctx context.Context, cluster string) error + func (s *Store) DropDB(ctx context.Context, cluster, database string) error + func (s *Store) EnforceRemoteRetention(ctx context.Context, cluster, database string, level int, maxTXID ltx.TXID) error + func (s *Store) FindClusters(ctx context.Context) ([]string, error) + func (s *Store) FindDBByName(ctx context.Context, cluster, name string) (*DB, error) + func (s *Store) FindDBsByCluster(ctx context.Context, cluster string) ([]*DB, error) + func (s *Store) FindStoragePathByTimestamp(ctx context.Context, cluster, database string, timestamp time.Time) (StoragePath, error) + func (s *Store) FindTXIDByTimestamp(ctx context.Context, cluster, database string, timestamp time.Time) (ltx.TXID, error) + func (s *Store) Info(ctx context.Context, cluster, database string, all bool) (*DBInfo, error) + func (s *Store) NextCompactionAt(level int) time.Time + func (s *Store) Open(ctx context.Context) error + func (s *Store) Path() string + func (s *Store) ProcessCompactions(ctx context.Context, dstLevel int) error + func (s *Store) RestoreToTx(ctx context.Context, cluster, database string, txID ltx.TXID) (ltx.TXID, error) + func (s *Store) StoreDatabase(ctx context.Context, cluster, database string, source io.Reader) (ltx.Pos, error) + func (s *Store) TempDir() string + func (s *Store) WriteDatabaseTo(ctx context.Context, cluster, name string, txID ltx.TXID, w io.Writer) error + func (s *Store) WriteLTXPageRangeFrom(ctx context.Context, cluster, database string, minTXID ltx.TXID, w io.Writer) (ltx.Header, ltx.Trailer, error) + func (s *Store) WriteLocalSnapshotTo(ctx context.Context, cluster, database string, txID ltx.TXID, w io.Writer) error + func (s *Store) WriteRemoteSnapshotTo(ctx context.Context, cluster, name string, txID ltx.TXID, w io.Writer) error + func (s *Store) WriteSnapshotTo(ctx context.Context, cluster, database string, txID ltx.TXID, w io.Writer) error + func (s *Store) WriteTx(ctx context.Context, cluster, database string, r io.Reader, ...) (ltx.Pos, error) + type Txn struct + Commit uint32 + DBID int + MaxTXID ltx.TXID + MinTXID ltx.TXID + PageSize uint32 + PostApplyChecksum ltx.Checksum + PreApplyChecksum ltx.Checksum + Timestamp time.Time + func (txn *Txn) PostApplyPos() ltx.Pos + func (txn *Txn) PreApplyPos() ltx.Pos + type WriteTxOptions struct + AppendSnapshot bool + Timestamp time.Time + type WriteTxPage struct + Data []byte + Pgno uint32 v0.1.4 Oct 6, 2024 v0.1.3 Oct 5, 2024 v0.1.2 Oct 5, 2024 v0.1.1 Oct 5, 2024