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 ¶
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 (*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 ¶
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.