blobstore

package
v0.0.0-...-4c1bd67 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHash

func NewHash() hash.Hash

NewHash is used to calculate checksums for the blob store.

Types

type ContentChallenge

type ContentChallenge struct {
	RequestId   string
	RangeStart  int64
	RangeLength int64
}

ContentChallenge holds a proof-of-content challenge produced by a blobstore. A client can satisfy the request by producing a ContentChallengeResponse containing the same request id and a hash of RangeLength bytes of the content starting at RangeStart.

type ContentChallengeError

type ContentChallengeError struct {
	Req ContentChallenge
}

ContentChallengeError holds a proof-of-content challenge produced by a blobstore.

func (*ContentChallengeError) Error

func (e *ContentChallengeError) Error() string

type ContentChallengeResponse

type ContentChallengeResponse struct {
	RequestId string
	Hash      string
}

ContentChallengeResponse holds a response to a ContentChallenge.

func NewContentChallengeResponse

func NewContentChallengeResponse(chal *ContentChallenge, r io.ReadSeeker) (*ContentChallengeResponse, error)

NewContentChallengeResponse can be used by a client to respond to a content challenge. The returned value should be passed to BlobStorage.Put when the client retries the request.

type ReadSeekCloser

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

type Store

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

Store stores data blobs in mongodb, de-duplicating by blob hash.

func New

func New(db *mgo.Database, prefix string) *Store

New returns a new blob store that writes to the given database, prefixing its collections with the given prefix.

func (*Store) Open

func (s *Store) Open(name string) (ReadSeekCloser, int64, error)

Open opens the entry with the given name.

func (*Store) Put

func (s *Store) Put(r io.Reader, name string, size int64, hash string, proof *ContentChallengeResponse) (*ContentChallenge, error)

Put tries to stream the content from the given reader into blob storage, with the provided name. The content should have the given size and hash. If the content is already in the store, a ContentChallengeError is returned containing a challenge that must be satisfied by a client to prove that they have access to the content. If the proof has already been acquired, it should be passed in as the proof argument.

func (*Store) PutUnchallenged

func (s *Store) PutUnchallenged(r io.Reader, name string, size int64, hash string) error

PutUnchallenged stream the content from the given reader into blob storage, with the provided name. The content should have the given size and hash. In this case a challenge is never returned and a proof is not required.

func (*Store) Remove

func (s *Store) Remove(name string) error

Remove the given name from the Store.

Jump to

Keyboard shortcuts

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