blob

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const HashSize = sha256.Size

HashSize is the number of bytes used in a Hash.

Variables

Set is used by wire.

Functions

This section is empty.

Types

type Blob

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

A Blob provides access to the contents of an immutable blob.

func (*Blob) Close

func (b *Blob) Close() error

Close implements io.Closer.

func (*Blob) Hash

func (b *Blob) Hash() Hash

Hash returns the content hash of the Blob.

func (*Blob) Length

func (b *Blob) Length() int64

Length returns the content length.

func (Blob) MarshalBinary

func (m Blob) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Blob) Read

func (b *Blob) Read(buf []byte) (int, error)

Read implements io.Reader.

func (*Blob) Seek

func (b *Blob) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker.

func (*Blob) String

func (b *Blob) String() string

func (Blob) UnmarshalBinary

func (m Blob) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Blob) WriteN

func (b *Blob) WriteN(w io.Writer, count int64) (int64, error)

WriteN writes up to count bytes from the current position into w.

func (*Blob) WriteTo

func (b *Blob) WriteTo(w io.Writer) (written int64, err error)

WriteTo implements io.WriterTo in order to improve efficiency with the io.Copy function.

type Hash

type Hash [HashSize]byte

Hash is a cryptographically-secure content-hash value.

func (Hash) MarshalBinary

func (h Hash) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Hash) String

func (h *Hash) String() string

func (*Hash) UnmarshalBinary

func (h *Hash) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type Store

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

Store provides access to blobs.

func ProvideStore

func ProvideStore(
	ctx context.Context,
	cache *cache.Cache,
	config *config.Config,
	db *pgxpool.Pool,
	logger *log.Logger,
) (*Store, func())

ProvideStore is used by wire.

func (*Store) CommitRope

func (s *Store) CommitRope(ctx context.Context, tID *tenant.ID, ropeID uuid.UUID, hash Hash) error

CommitRope associates a content hash with the given rope.

func (*Store) EnsureBlob

func (s *Store) EnsureBlob(ctx context.Context, tID *tenant.ID, data io.Reader) (Hash, error)

EnsureBlob will insert the contents provided by the given reader into the database, returning a content hash.

This method is idempotent.

func (*Store) InsertToRope

func (s *Store) InsertToRope(
	ctx context.Context,
	tID *tenant.ID,
	ropeID uuid.UUID,
	data io.Reader,
	hasher hash.Hash,
	offset int64,
) (int64, error)

InsertToRope will append contents provided by the given reader to the given rope, starting at the specified offset. The data will also be fed to the given hash function.

func (*Store) OpenBlob

func (s *Store) OpenBlob(ctx context.Context, tID *tenant.ID, hash Hash) (*Blob, error)

OpenBlob returns an encapsulation of a blob with the given hash. This method returns os.ErrNotExist if no blob with the given content hash exists.

Jump to

Keyboard shortcuts

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