blob

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package blob stores raw messages by content: each blob is a file named by the hex SHA-256 of its bytes, under <dir>/<first two hex digits>/<sha> (docs/design/storage.md).

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidID = errors.New("blob: invalid id")

ErrInvalidID rejects anything but 64 lowercase hex digits, so an ID can never name a path outside the store.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a directory of immutable blobs. It is safe for concurrent use.

func New

func New(dir string) *Store

New returns a Store rooted at dir, which is created (0700) on first Put.

func (*Store) Has

func (s *Store) Has(id string) (bool, error)

Has reports whether the blob exists; a malformed id returns ErrInvalidID.

func (*Store) Open

func (s *Store) Open(id string) (io.ReadCloser, error)

Open returns the blob's content. A missing blob returns an error matching fs.ErrNotExist; a malformed id returns ErrInvalidID.

func (*Store) Put

func (s *Store) Put(ctx context.Context, r io.Reader) (string, error)

Put copies r into the store and returns the blob's ID. Content already stored is not written twice. The blob appears atomically: r is streamed to a temporary file in the store directory while hashing, synced, and renamed into place. Directories are 0700 and blobs 0600. If ctx is done before the rename, Put returns ctx.Err() and leaves nothing behind.

func (*Store) Remove

func (s *Store) Remove(id string) error

Remove deletes the blob. A missing blob is not an error; a malformed id returns ErrInvalidID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL