Documentation
¶
Index ¶
- type MemoryStorage
- func (ms *MemoryStorage) Close() error
- func (ms *MemoryStorage) DeleteChunk(ctx context.Context, hash core.Hash) error
- func (ms *MemoryStorage) DeleteRef(ctx context.Context, name string) error
- func (ms *MemoryStorage) DeleteSnapshot(ctx context.Context, id core.SnapshotID) error
- func (ms *MemoryStorage) GetChunk(ctx context.Context, hash core.Hash) (*core.Chunk, error)
- func (ms *MemoryStorage) GetConfig(ctx context.Context) (*core.Config, error)
- func (ms *MemoryStorage) GetIndex(ctx context.Context) (*core.Index, error)
- func (ms *MemoryStorage) GetPreview(ctx context.Context, hash core.Hash, size int) ([]byte, error)
- func (ms *MemoryStorage) GetRef(ctx context.Context, name string) (*core.Reference, error)
- func (ms *MemoryStorage) GetSnapshot(ctx context.Context, id core.SnapshotID) (*core.Snapshot, error)
- func (ms *MemoryStorage) HasChunk(ctx context.Context, hash core.Hash) (bool, error)
- func (ms *MemoryStorage) ListChunks(ctx context.Context) ([]core.Hash, error)
- func (ms *MemoryStorage) ListRefs(ctx context.Context, prefix string) ([]*core.Reference, error)
- func (ms *MemoryStorage) ListSnapshots(ctx context.Context, opts *storage.ListOptions) ([]*core.SnapshotSummary, error)
- func (ms *MemoryStorage) PutChunk(ctx context.Context, chunk *core.Chunk) error
- func (ms *MemoryStorage) PutPreview(ctx context.Context, hash core.Hash, size int, data []byte) error
- func (ms *MemoryStorage) PutSnapshot(ctx context.Context, snapshot *core.Snapshot) error
- func (ms *MemoryStorage) SetCompressionConfig(enabled bool, level int) error
- func (ms *MemoryStorage) SetConfig(ctx context.Context, config *core.Config) error
- func (ms *MemoryStorage) SetIndex(ctx context.Context, index *core.Index) error
- func (ms *MemoryStorage) SetRef(ctx context.Context, name string, ref *core.Reference) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage implements storage.Storer entirely in memory. All methods are safe for concurrent use: a sync.RWMutex protects every map and pointer field. Read operations acquire a read lock; write operations acquire a write lock.
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new in-memory storage.
func (*MemoryStorage) Close ¶
func (ms *MemoryStorage) Close() error
Close releases any resources held by the memory storage. It is a no-op.
func (*MemoryStorage) DeleteChunk ¶
DeleteChunk removes a chunk. It is idempotent.
func (*MemoryStorage) DeleteRef ¶
func (ms *MemoryStorage) DeleteRef(ctx context.Context, name string) error
DeleteRef removes a reference.
func (*MemoryStorage) DeleteSnapshot ¶
func (ms *MemoryStorage) DeleteSnapshot(ctx context.Context, id core.SnapshotID) error
DeleteSnapshot removes a snapshot and its manifest. It is idempotent.
func (*MemoryStorage) GetConfig ¶
GetConfig returns the stored configuration, cloned and normalized to match the filesystem backend's invariants (chunk size clamping and field normalization).
func (*MemoryStorage) GetPreview ¶
GetPreview is a noop stub (Phase 1).
func (*MemoryStorage) GetRef ¶
GetRef reads a reference. If the reference is a symbolic reference, Target is resolved by recursively reading the referenced ref.
func (*MemoryStorage) GetSnapshot ¶
func (ms *MemoryStorage) GetSnapshot(ctx context.Context, id core.SnapshotID) (*core.Snapshot, error)
GetSnapshot retrieves a snapshot and verifies its integrity by recomputing the BLAKE3 hash of its marshaled proto (with IdHash omitted), mirroring the filesystem backend. A mismatch indicates corruption and returns storage.ErrCorrupted so callers can handle it uniformly.
func (*MemoryStorage) ListChunks ¶
ListChunks returns the hashes of all stored chunks. The order of the returned slice is not guaranteed.
func (*MemoryStorage) ListRefs ¶
ListRefs lists all references matching the given prefix. HEAD is excluded to match the filesystem backend, which only walks the refs/ directory (HEAD lives at the repository root, outside refs/). Each ref is resolved via getRefRecursiveLocked so symrefs have their Target populated and Type derived from the name, matching the filesystem backend.
Only ErrNotFound errors from resolution are skipped (e.g. dangling symref); other errors are propagated so callers can distinguish I/O failures from missing refs.
func (*MemoryStorage) ListSnapshots ¶
func (ms *MemoryStorage) ListSnapshots(ctx context.Context, opts *storage.ListOptions) ([]*core.SnapshotSummary, error)
ListSnapshots lists all snapshots via lightweight manifests, sorted by timestamp descending, with optional limit/offset pagination. Returns snapshot summaries without file lists — call GetSnapshot for full details.
func (*MemoryStorage) PutChunk ¶
PutChunk stores a chunk. The chunk data is verified against its declared hash before storing, consistent with the filesystem backend, so a caller-supplied mismatch can never reach the store.
func (*MemoryStorage) PutPreview ¶
func (ms *MemoryStorage) PutPreview(ctx context.Context, hash core.Hash, size int, data []byte) error
PutPreview is a noop stub (Phase 1).
func (*MemoryStorage) PutSnapshot ¶
PutSnapshot stores a snapshot and caches its lightweight manifest.
func (*MemoryStorage) SetCompressionConfig ¶
func (ms *MemoryStorage) SetCompressionConfig(enabled bool, level int) error
SetCompressionConfig is a no-op for the in-memory backend, which does not compress chunks. Implementing it satisfies storage.ConfigStorer so porcelain can apply config uniformly across backends without type-asserting to a concrete implementation.