blobref

package
v0.0.0-...-3b294e6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2013 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Pattern = `\b([a-z][a-z0-9]*)-([a-f0-9]+)\b`

Pattern is the regular expression which matches a blobref. It does not contain ^ or $.

Variables

This section is empty.

Functions

func NewHash

func NewHash() hash.Hash

NewHash returns a new hash.Hash of the currently recommended hash type. Currently this is just SHA-1, but will likely change within the next year or so.

Types

type BlobRef

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

BlobRef is an immutable reference to a blob.

func FromHash

func FromHash(h hash.Hash) *BlobRef

FromHash returns a BlobRef representing the given hash.

func FromPattern

func FromPattern(r *regexp.Regexp, s string) *BlobRef

FromPattern takes a pattern and if it matches 's' with two exactly two valid submatches, returns a BlobRef, else returns nil.

func MustParse

func MustParse(ref string) *BlobRef

func Parse

func Parse(ref string) *BlobRef

func ParseMulti

func ParseMulti(refs []string) (parsed []*BlobRef)

May return nil in list positions where the blobref could not be parsed.

func SHA1FromString

func SHA1FromString(s string) *BlobRef

SHA1FromString returns a SHA-1 blobref of the provided string.

func (*BlobRef) Digest

func (b *BlobRef) Digest() string

func (*BlobRef) DigestPrefix

func (b *BlobRef) DigestPrefix(digits int) string

func (*BlobRef) DomID

func (b *BlobRef) DomID() string

func (*BlobRef) Equal

func (o *BlobRef) Equal(other *BlobRef) bool

func (*BlobRef) GobDecode

func (br *BlobRef) GobDecode(b []byte) error

func (*BlobRef) GobEncode

func (br *BlobRef) GobEncode() ([]byte, error)

func (*BlobRef) Hash

func (o *BlobRef) Hash() hash.Hash

func (*BlobRef) HashMatches

func (o *BlobRef) HashMatches(h hash.Hash) bool

func (*BlobRef) HashName

func (b *BlobRef) HashName() string

func (*BlobRef) IsSupported

func (o *BlobRef) IsSupported() bool

func (*BlobRef) MarshalJSON

func (br *BlobRef) MarshalJSON() ([]byte, error)

func (*BlobRef) String

func (b *BlobRef) String() string

func (*BlobRef) Sum32

func (o *BlobRef) Sum32() uint32

func (*BlobRef) UnmarshalJSON

func (br *BlobRef) UnmarshalJSON(d []byte) error

type ChanPeeker

type ChanPeeker struct {
	Ch <-chan SizedBlobRef
	// contains filtered or unexported fields
}

TODO: use Generics if/when available

func (*ChanPeeker) Closed

func (cp *ChanPeeker) Closed() bool

func (*ChanPeeker) ConsumeAll

func (cp *ChanPeeker) ConsumeAll()

func (*ChanPeeker) Peek

func (cp *ChanPeeker) Peek() *SizedBlobRef

func (*ChanPeeker) Take

func (cp *ChanPeeker) Take() *SizedBlobRef

type DirFetcher

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

func NewConfigDirFetcher

func NewConfigDirFetcher() *DirFetcher

func NewSimpleDirectoryFetcher

func NewSimpleDirectoryFetcher(dir string) *DirFetcher

func (*DirFetcher) Fetch

func (df *DirFetcher) Fetch(b *BlobRef) (file ReadSeekCloser, size int64, err error)

func (*DirFetcher) FetchStreaming

func (df *DirFetcher) FetchStreaming(b *BlobRef) (file io.ReadCloser, size int64, err error)

type MemoryStore

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

MemoryStore stores blobs in memory and is a Fetcher and StreamingFetcher. Its zero value is usable.

func (*MemoryStore) AddBlob

func (s *MemoryStore) AddBlob(hashtype crypto.Hash, data string) (*BlobRef, error)

func (*MemoryStore) FetchStreaming

func (s *MemoryStore) FetchStreaming(b *BlobRef) (file io.ReadCloser, size int64, err error)

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

type SeekFetcher

type SeekFetcher interface {
	// Fetch returns a blob.  If the blob is not found then
	// os.ErrNotExist should be returned for the error (not a wrapped
	// error with a ErrNotExist inside)
	//
	// The caller should close blob.
	Fetch(*BlobRef) (blob ReadSeekCloser, size int64, err error)
}

func NewSerialFetcher

func NewSerialFetcher(fetchers ...SeekFetcher) SeekFetcher

func SeekerFromStreamingFetcher

func SeekerFromStreamingFetcher(f StreamingFetcher) SeekFetcher

SeekerFromStreamingFetcher returns the most efficient implementation of a seeking fetcher from a provided streaming fetcher.

type SeekTester

type SeekTester interface {
	IsFetcherASeeker() bool
}

SeekTester is the interface implemented by storage implementations that don't know until runtime whether or not their StreamingFetcher happens to also return a ReadCloser that's also a ReadSeekCloser.

type SizedBlobRef

type SizedBlobRef struct {
	*BlobRef
	Size int64
}

SizedBlobRef is like a BlobRef but includes because it includes a potentially mutable 'Size', this should be used as a stack value, not a *SizedBlobRef.

func (*SizedBlobRef) Equal

func (sb *SizedBlobRef) Equal(o SizedBlobRef) bool

func (SizedBlobRef) String

func (sb SizedBlobRef) String() string

type StreamingFetcher

type StreamingFetcher interface {
	// FetchStreaming returns a blob.  If the blob is not found then
	// os.ErrNotExist should be returned for the error (not a wrapped
	// error with a ErrNotExist inside)
	//
	// The caller should close blob.
	FetchStreaming(*BlobRef) (blob io.ReadCloser, size int64, err error)
}

func NewSerialStreamingFetcher

func NewSerialStreamingFetcher(fetchers ...StreamingFetcher) StreamingFetcher

Jump to

Keyboard shortcuts

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