Documentation
¶
Overview ¶
Package cas stores immutable blobs by their SHA-256 digest.
Fold pointers make graph reachability explicit. Garbage collection remains intentionally out of scope: immutable overflow is kept until a later pass can prove that no journal event refers to it.
Index ¶
- Constants
- Variables
- func Reference(ref Ref, originalPath string) string
- func SourcePath(reference string) string
- type Ref
- type Store
- func (s *Store) Get(ref Ref) (io.ReadCloser, error)
- func (s *Store) Path(ref Ref) (string, error)
- func (s *Store) Put(reader io.Reader) (Ref, error)
- func (s *Store) PutBytes(data []byte) (Ref, error)
- func (s *Store) PutFile(path string) (Ref, error)
- func (s *Store) Stat(ref Ref) (size int64, exists bool, err error)
- func (s *Store) Verify(ref Ref) error
Constants ¶
const Scheme = "cas://"
Scheme prefixes a durable attachment reference.
Variables ¶
var ( // ErrInvalidRef means a reference is not a hexadecimal SHA-256 digest. ErrInvalidRef = errors.New("invalid cas ref") // ErrContentMismatch means stored bytes no longer hash to their reference. ErrContentMismatch = errors.New("cas content does not match ref") )
Functions ¶
func Reference ¶
A reference is written as cas://<digest>/<the path the user attached>, and the shape is deliberate. The digest is the durable half: the bytes live in the store under it, so a job retried next week reads exactly what was attached even if the person has since moved, renamed, or deleted their copy. The path is the honest half: it is what the attachment is called, where it came from, and what every reader — a chip in the composer, the compiler's list of attached documents, filepath.Ext — needs to see. Keeping the path at the tail means those readers keep working on a reference unchanged, and a reference read by something that knows nothing about this format still says out loud which file it means.
func SourcePath ¶
SourcePath is what a reader that only understands paths should look at: the file the person attached. It is unchanged for anything that is already a path.
Types ¶
type Ref ¶
type Ref string
Ref is the lowercase hexadecimal SHA-256 digest of a blob.
func DigestBytes ¶
DigestBytes names content without storing it, for callers that need the same identity the store uses — a staged copy's suffix, a duplicate check.
func ParseReference ¶
ParseReference splits a durable reference into its digest and the path it was made from. Anything that is not a reference comes back unchanged as a path, so a caller can hold both kinds in one list.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a content-addressed collection of immutable blobs.
func (*Store) Get ¶
func (s *Store) Get(ref Ref) (io.ReadCloser, error)
Get opens a stored blob for reading.