blobstore

package
v0.0.0-...-b84bf83 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2014 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBIDCollision = errors.New("A colliding BID has been found")
	ErrBIDNotFound  = errors.New("A blob with given BID was not found")
)
View Source
var (
	ErrInsufficientKeySource = errors.New("Not enough data to create a proper encryption key")
	ErrInvalidKey            = errors.New("Invalid key")
	ErrUnknownKeyType        = errors.New("Unknown key type")
)
View Source
var (
	ErrInvalidValidationMethod = errors.New("Invalid blob validation method")

	ErrInvalidFileBlobType              = errors.New("Invalid blob type - not a file blob")
	ErrInvalidSplitFileSize             = errors.New("Invalid size of a split file")
	ErrMalformedSplitFileSizePartsCount = errors.New("Invalid split file blob - number of partial blobs is incorrect")
	ErrMalformedSplitFileExtraData      = errors.New("Invalid split file blob - extra bytes found at the end of the blob")
	ErrMalformedSplitFileExtraDataPart  = errors.New("Invalid split file blob - extra bytes found at the end of the partial blob")
	ErrInvalidFileSubBlobType           = errors.New("Invalid sub blob type - not a file blob")

	ErrMalformedDirInvalidEntriesCount = errors.New("Invalid directory blob - incorrect number of entries found")
	ErrMalformedDirExtraData           = errors.New("Invalid directory blob - extra bytes found at the end")
	ErrNoMoreDirEntries                = errors.New("No more directory entries found")

	ErrInvalidPublicKeyBid  = errors.New("Invalid public key - does not match blob id")
	ErrUnknownPublicKeyType = errors.New("Unknown public key type")
)
View Source
var (
	ErrDeserializeStringToLarge = errors.New("Could not deserialize string value due to invalid length")
	ErrDeserializeStringNotUTF8 = errors.New("Could not deserialize string value - not a UTF-8 sequence")
)

Functions

This section is empty.

Types

type BlobStorage

type BlobStorage interface {

	// Create new writer for blobs
	NewBlobWriter(blobId string) (writer WriteFinalizeCanceler, err error)

	// Create new reader for existing blob
	NewBlobReader(blobId string) (reader io.Reader, err error)
}

An interface usefull for blob storage operations

func NewFileBlobStorage

func NewFileBlobStorage(path string) BlobStorage

func NewMemoryBlobStorage

func NewMemoryBlobStorage() BlobStorage

type DirBlobReader

type DirBlobReader interface {
	// Open blob for reading
	Open(bid, key string) error

	// Test whether there's any more entry left
	IsNextEntry() bool

	// Get the next entry from the reader
	NextEntry() (DirEntry, error)
}

func NewDirBlobReader

func NewDirBlobReader(storage BlobStorage) DirBlobReader

type DirBlobWriter

type DirBlobWriter struct {

	// Storage Object
	Storage BlobStorage
	// contains filtered or unexported fields
}

Structure used for creating new directory blobs

func (*DirBlobWriter) AddEntry

func (d *DirBlobWriter) AddEntry(entry DirEntry) error

Adds a new entry to the directory TODO: Don't allow adding duplicated entries

func (*DirBlobWriter) Finalize

func (d *DirBlobWriter) Finalize() (bid string, key string, err error)

type DirEntry

type DirEntry struct {
	Name, MimeType, Bid, Key string
}

Helper structure for holding one directory entry

type FileBlobReader

type FileBlobReader interface {
	io.Reader

	Open(bid, key string) error
}

func NewFileBlobReader

func NewFileBlobReader(storage BlobStorage) FileBlobReader

type FileBlobWriter

type FileBlobWriter struct {

	// Storage object
	Storage BlobStorage
	// contains filtered or unexported fields
}

Structure used to generate static file blobs

func (*FileBlobWriter) Cancel

func (f *FileBlobWriter) Cancel()

Cancel the generation of file blob.

Note that if there were blobs generated so far, they won't be removed. The current implementation allows such garbage favouring the simplicity of implementation.

func (*FileBlobWriter) Finalize

func (f *FileBlobWriter) Finalize() (bid string, key string, err error)

Finalize the generation of this file blob

func (*FileBlobWriter) Write

func (f *FileBlobWriter) Write(p []byte) (n int, err error)

Performing a write operation on the file blob

type WriteFinalizeCanceler

type WriteFinalizeCanceler interface {
	io.Writer

	// Finalize blob generation, if no error is returned,
	// the duplicate flag will indicate whether this blob
	// was already inside the blobstore and is equal to the
	// new one written
	Finalize() error

	// Cancel the blob generation
	Cancel() error
}

Jump to

Keyboard shortcuts

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