Documentation
¶
Overview ¶
Package blob stores object payloads as content-addressed files.
Bytes never sit in the heap in full: an upload streams from the request body through the hashers to a temp file in one pass, and a download is served from the file. Memory stays flat whatever the object's size — the property fake-gcs-server does not have, where a 2 GB file has driven RSS past 12 GB.
Index ¶
- Variables
- type Ref
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(sha256hex string) error
- func (s *Store) Fork() (*Store, error)
- func (s *Store) Open(sha256hex string) (*os.File, error)
- func (s *Store) Path(sha256hex string) string
- func (s *Store) Put(ctx context.Context, r io.Reader) (Ref, error)
- func (s *Store) Reset() error
- func (s *Store) Root() string
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("blob: not found")
ErrNotFound is returned for a digest the store does not hold.
Functions ¶
This section is empty.
Types ¶
type Ref ¶
type Ref struct {
// SHA256 is the content address, lowercase hex.
SHA256 string
Size int64
// CRC32C is base64 of the four big-endian checksum bytes, as GCS spells it.
CRC32C string
// MD5 is base64 of the digest, as GCS spells it.
MD5 string
}
Ref describes stored content: its address, and the checksums GCS reports.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a content-addressed blob tree rooted at a directory.
func (*Store) Delete ¶
Delete removes content. Deleting what is not there is not an error: the caller wanted it gone.
func (*Store) Fork ¶
Fork returns a new store holding the same content, in its own directory.
The files are hardlinked, not copied: content here is immutable and addressed by its own hash, so two trees can share the bytes on disk. What they do not share is the right to delete — dropping the last reference in one store removes only that store's link, leaving the other's intact. That is the whole difficulty a shared tree has: a parent overwriting an object would otherwise pull the content out from under a fork still pointing at it.
func (*Store) Path ¶
Path is where a digest's content lives. Exported so a handler can hand the file to http.ServeContent, which streams and handles Range itself.
func (*Store) Put ¶
Put streams r into the tree and returns its Ref.
One pass: the reader is copied into the temp file and all three hashes at once, so the bytes are never read twice and never held whole.