cafs

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLeafSize = 2 * 1024 * 1024
	MaxLeafSize     = 5 * 1024 * 1024
)
View Source
const (
	// KeySize for blake2b algo
	KeySize = 64

	// KeySizeHex for hex representation of a key
	KeySizeHex = 66
)

Variables

This section is empty.

Functions

func CopyPaddedJSON

func CopyPaddedJSON(w io.Writer, buf *bytes.Buffer)

func GenerateCAFSFile

func GenerateCAFSFile(src string, fs Fs, destDir string) error

func GenerateFile

func GenerateFile(tgt string, size int, leafSize uint32) error

func IsRootKey

func IsRootKey(fs storage.Store, key Key, leafSize uint32) bool

Types

type BadKeySize

type BadKeySize struct {
	Key []byte
}

BadKeySize is an error that's returned when the key to create has an invalid size.

func (*BadKeySize) Error

func (b *BadKeySize) Error() string

type Fs

type Fs interface {
	Get(context.Context, Key) (io.ReadCloser, error)
	GetAt(context.Context, Key) (io.ReaderAt, error)
	Put(context.Context, io.Reader) (PutRes, error)
	Delete(context.Context, Key) error
	Clear(context.Context) error
	Keys(context.Context) ([]Key, error)
	RootKeys(context.Context) ([]Key, error)
	Has(context.Context, Key, ...HasOption) (bool, []Key, error)
}

Fs implementations provide content-addressable filesystem operations

func New

func New(opts ...Option) (Fs, error)

New creates a new file system operations instance for a repository

type HasOption

type HasOption func(*hasOpts)

func HasGatherIncomplete

func HasGatherIncomplete() HasOption

func HasOnlyRoots

func HasOnlyRoots() HasOption

type Key

type Key [KeySize]byte

Key type for CAFS keys

func GenerateCAFSChunks

func GenerateCAFSChunks(src string, fs Fs) (*Key, error)

func KeyFromString

func KeyFromString(kv string) (Key, error)

func LeafKeys

func LeafKeys(verify Key, data []byte, leafSize uint32) ([]Key, error)

func LeafsForHash

func LeafsForHash(blobs storage.Store, hash Key, leafSize uint32, prefix string) ([]Key, error)

func MustNewKey

func MustNewKey(data []byte) Key

MustNewKey creates a new key from data but panics if there is an error

func NewKey

func NewKey(data []byte) (Key, error)

NewKey creates a new key from data

func RootHash

func RootHash(leaves []Key, leafSize uint32) (Key, error)

func (Key) String

func (k Key) String() string

func (Key) StringWithPrefix

func (k Key) StringWithPrefix(prefix string) string

type Option

type Option func(*defaultFs)

Option to configure content addressable FS components

func Backend

func Backend(store storage.Store) Option

func ConcurrentFlushes

func ConcurrentFlushes(concurrentFlushes int) Option

func LeafSize

func LeafSize(sz uint32) Option

LeafSize configuration for the blake2b hashes

func LeafTruncation

func LeafTruncation(a bool) Option

func Prefix

func Prefix(prefix string) Option

func ReaderConcurrentChunkWrites

func ReaderConcurrentChunkWrites(readerConcurrentChunkWrites int) Option

type PutRes

type PutRes struct {
	Written int64
	Key     Key
	Keys    []byte
	Found   bool
}

type Reader

type Reader interface {
	io.ReadCloser
	io.ReaderAt
}

type ReaderOption

type ReaderOption func(reader *chunkReader)

func ConcurrentChunkWrites

func ConcurrentChunkWrites(concurrentChunkWrites int) ReaderOption

func Keys

func Keys(keys []Key) ReaderOption

func SetCache

func SetCache(lru *lru.Cache) ReaderOption

func SetLeafPool

func SetLeafPool(leafPool *leafFreelist) ReaderOption

func TruncateLeaf

func TruncateLeaf(t bool) ReaderOption

func VerifyHash

func VerifyHash(t bool) ReaderOption

type Writer

type Writer interface {
	io.WriteCloser
	Flush() (Key, []byte, error)
}

Writer interface for a content addressable FS

Jump to

Keyboard shortcuts

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