Documentation ¶
Index ¶
- Constants
- func NewHash() hash.Hash
- type BlobRef
- func (br *BlobRef) Digest() string
- func (br *BlobRef) DigestPrefix(digits int) string
- func (br *BlobRef) DomID() string
- func (br *BlobRef) Equal(other *BlobRef) bool
- func (br *BlobRef) GobDecode(b []byte) error
- func (br *BlobRef) GobEncode() ([]byte, error)
- func (br *BlobRef) Hash() hash.Hash
- func (br *BlobRef) HashMatches(h hash.Hash) bool
- func (br *BlobRef) HashName() string
- func (br *BlobRef) IsSupported() bool
- func (br *BlobRef) MarshalJSON() ([]byte, error)
- func (br *BlobRef) String() string
- func (br *BlobRef) Sum32() uint32
- func (br *BlobRef) UnmarshalJSON(d []byte) error
- type ChanPeeker
- type DirFetcher
- type MemoryStore
- type ReadSeekCloser
- type SeekFetcher
- type SeekTester
- type SizedBlobRef
- type StreamingFetcher
Constants ¶
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 ¶
Types ¶
type BlobRef ¶
type BlobRef struct {
// contains filtered or unexported fields
}
BlobRef is an immutable reference to a blob.
func FromPattern ¶
FromPattern takes a pattern and if it matches 's' with two exactly two valid submatches, returns a BlobRef, else returns nil.
func ParseMulti ¶
May return nil in list positions where the blobref could not be parsed.
func SHA1FromBytes ¶
SHA1FromBytes returns a SHA-1 blobref of the provided bytes.
func SHA1FromString ¶
SHA1FromString returns a SHA-1 blobref of the provided string.
func (*BlobRef) DigestPrefix ¶
func (*BlobRef) IsSupported ¶
func (*BlobRef) MarshalJSON ¶
func (*BlobRef) UnmarshalJSON ¶
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) FetchStreaming ¶
func (s *MemoryStore) FetchStreaming(b *BlobRef) (file io.ReadCloser, size int64, err error)
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 ¶
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