diff options
| author | 2026-03-30 13:53:54 +0000 | |
|---|---|---|
| committer | 2026-03-30 13:54:27 +0000 | |
| commit | 238b2caf83dde3c4395109c51b8c9affa6e11890 (patch) | |
| tree | e9d946bea08515c2d86954ea617a237710f9f2bf /object/store/packed/internal/reading/store.go | |
| parent | object/store/memory: Remove AddObject, fix lints (diff) | |
| signature | No signature | |
object/store/packed: Start the internal/reading split
Diffstat (limited to 'object/store/packed/internal/reading/store.go')
| -rw-r--r-- | object/store/packed/internal/reading/store.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/object/store/packed/internal/reading/store.go b/object/store/packed/internal/reading/store.go new file mode 100644 index 00000000..cb4829ab --- /dev/null +++ b/object/store/packed/internal/reading/store.go @@ -0,0 +1,52 @@ +package reading + +import ( + "os" + "sync" + "sync/atomic" + + objectid "codeberg.org/lindenii/furgit/object/id" + objectstore "codeberg.org/lindenii/furgit/object/store" +) + +// Store reads Git objects from pack/index files under an objects/pack root. +// +// Cached pack/index mappings are retained until Close. +// +// Labels: Close-Caller. +type Store struct { + // root is the borrowed objects/pack capability used for all file access. + root *os.Root + // algo is the expected object ID algorithm for lookups. + algo objectid.Algorithm + // refreshPolicy controls automatic candidate refresh on lookup misses. + refreshPolicy RefreshPolicy + + // candidates stores the latest immutable candidate snapshot. + candidates atomic.Pointer[candidateSnapshot] + // refreshMu serializes candidate refresh. + refreshMu sync.Mutex + // mruMu guards candidate MRU linked-list state. + mruMu sync.RWMutex + // mruHead is the first pack in MRU order. + mruHead *packCandidateNode + // mruTail is the last pack in MRU order. + mruTail *packCandidateNode + // mruNodeByPack maps pack basename to MRU node. + mruNodeByPack map[string]*packCandidateNode + // idxByPack caches opened and parsed indexes by pack basename. + idxByPack map[string]*idxFile + + // stateMu guards pack cache and close state. + stateMu sync.RWMutex + // idxMu guards parsed index cache. + idxMu sync.RWMutex + // cacheMu guards delta cache operations. + cacheMu sync.RWMutex + // packs caches opened .pack handles by basename. + packs map[string]*packFile + // deltaCache caches resolved base objects by pack location. + deltaCache *deltaCache +} + +var _ objectstore.Reader = (*Store)(nil) |
