Documentation
¶
Overview ¶
Package storage provides a filesystem based storage layer for tony system api.
Storage manages
mappings of virtual document paths to and from the filesyste
indexing of virtual document nodes
storage of diffs associated with virtual document nodes
transactions of multi-participant diffs
compaction of diffs
Index ¶
- type PatchAtSegment
- type Storage
- func (s *Storage) Close() error
- func (s *Storage) GetCurrentCommit() (int64, error)
- func (s *Storage) GetTx(txID int64) (tx.Tx, error)
- func (s *Storage) NewTx(participantCount int, meta *api.PatchMeta) (tx.Tx, error)
- func (s *Storage) ReadCurrentState(kPath string) (*ir.Node, error)
- func (s *Storage) ReadPatchesAt(kp string, commit int64) ([]PatchAtSegment, error)
- func (s *Storage) ReadStateAt(kPath string, commit int64) (*ir.Node, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PatchAtSegment ¶ added in v0.0.10
type PatchAtSegment struct {
Segment *index.LogSegment
Patch *ir.Node // Extracted patch at segment.KindedPath
Parent *ir.Node // Reconstructed parent patch (if segment.KindedPath is deep)
}
PatchAtSegment represents a patch extracted from a log segment.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage provides filesystem-based storage for logd.
func Open ¶
Open opens or creates a Storage instance with the given root directory. The root directory will be created if it doesn't exist. umask is applied to directory permissions (e.g., 022 for 0755 -> 0755). If logger is nil, slog.Default() will be used. compactorConfig is optional - if nil, a default config with divisor 2 and NeverRemove is used.
func (*Storage) GetCurrentCommit ¶ added in v0.0.10
GetCurrentCommit returns the current commit number. This is a snapshot - if commits happen after this call, they won't be reflected.
func (*Storage) GetTx ¶ added in v0.0.10
GetTx gets an existing transaction by transaction ID. This is the primary way participants coordinate - they all receive the same transaction ID and get the same transaction.
Example:
// Multiple parallel HTTP handlers all receive the same txID
tx, err := storage.GetTx(txID)
if err != nil {
// handle error
}
// Each participant gets their own patcher handle
patcher := tx.NewPatcher(kp, m, p)
result := patcher.Commit()
func (*Storage) NewTx ¶ added in v0.0.10
NewTx creates a new transaction with the specified number of participants. Returns a transaction that participants can get via GetTx or get a patcher via NewPatcher().
Example usage (typical pattern for parallel HTTP handlers):
// Create transaction
tx, err := storage.NewTx(participantCount, meta)
if err != nil {
// handle error
}
// Each participant gets their own patcher handle
patcher := tx.NewPatcher(kp, m, p)
result := patcher.WaitForCompletion()
func (*Storage) ReadCurrentState ¶ added in v0.0.10
ReadCurrentState reads the current committed state for a given virtual path. This is equivalent to calling GetCurrentCommit() then ReadStateAt() with that commit. If commits happen between getting the commit and reading, they are ignored (point-in-time read).
func (*Storage) ReadPatchesAt ¶ added in v0.0.10
func (s *Storage) ReadPatchesAt(kp string, commit int64) ([]PatchAtSegment, error)
ReadPatchesAt reads all patches affecting the given kpath at the given commit. Returns patches extracted from log entries, including sub-trees and reconstructed parents. This is a testing/development helper - it doesn't apply or merge patches.
func (*Storage) ReadStateAt ¶ added in v0.0.10
ReadStateAt reads the state for a given kpath at a specific commit count. Currently implements a simple approach: applies all patches from the beginning. Future optimizations: snapshots, compaction, caching.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package index provides hierarchical path-based indexing for storage.
|
Package index provides hierarchical path-based indexing for storage. |
|
internal
|
|
|
dlog
Package dlog provides double-buffered write-ahead logging.
|
Package dlog provides double-buffered write-ahead logging. |
|
seq
Package seq provides atomic sequence counters.
|
Package seq provides atomic sequence counters. |
|
snap
Package snap provides event-based snapshot storage.
|
Package snap provides event-based snapshot storage. |
|
snap/archive
Package archive contains the deprecated IR-node-based snapshot implementation.
|
Package archive contains the deprecated IR-node-based snapshot implementation. |
|
Package tx provides transaction coordination for multi-participant updates.
|
Package tx provides transaction coordination for multi-participant updates. |