v1data

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//LogGroup is the group for each log statement.
	LogGroup = "DataClient"
	//NoOfRetries is the amount of retries when uploading or downloading to S3.
	NoOfRetries = 2
)
View Source
const (
	//IndexObjectKey is the key of the object that contains an index of all the chunks of a dataset.
	IndexObjectKey = "index"
	//UploadPolynomal is the polynomal that is used for chunked uploading.
	UploadPolynomal = 0x3DA3358B4DC173
)
View Source
const (
	//MetadataObjectKey is the key of the object that contains an a dataset's metadata.
	MetadataObjectKey = "metadata"
)

Variables

View Source
var ZeroKey = Key{}

ZeroKey is an empty key.

Functions

This section is empty.

Types

type Client

type Client struct {
	DataOps DataOps
}

Client holds a reference to an AWS session

func NewClient

func NewClient(ops DataOps) *Client

NewClient creates a new data client that is capable of uploading and downloading (multiple) files.

func (*Client) Download

func (c *Client) Download(ctx context.Context, bucket, key string) (io.ReadCloser, error)

Download downloads a single object.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, bucket, key string) (has bool, err error)

Exists checks if a given object key exists.

func (*Client) MetadataDownload

func (c *Client) MetadataDownload(ctx context.Context, bucket, root string) (*v1payload.Metadata, error)

MetadataDownload downloads a dataset's metadata.

func (*Client) MetadataExists

func (c *Client) MetadataExists(ctx context.Context, bucket, root string) (bool, error)

MetadataExists checks if the metadata object exists.

func (*Client) MetadataUpload

func (c *Client) MetadataUpload(ctx context.Context, bucket, root string, m *v1payload.Metadata) error

MetadataUpload uploads a dataset's metadata.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, bucket, key string, body io.ReadSeeker) error

Upload uploads a single object.

type DataOps

type DataOps interface {
	Upload(ctx context.Context, bucket, key string, body io.ReadSeeker) error
	Download(ctx context.Context, bucket, key string) (body io.ReadCloser, err error)
	Exists(ctx context.Context, bucket, key string) (exists bool, err error)
}

DataOps is an interface to a set of data operations. The interface can be implemented to store / retrieve data from different data backends.

type IndexReader

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

IndexReader can be used to read keys from the "index" object.

func NewIndexReader

func NewIndexReader(r io.Reader) *IndexReader

NewIndexReader creates a new IndexReader.

func (*IndexReader) ReadKey

func (r *IndexReader) ReadKey() (Key, error)

ReadKey reads Keys from the provided io.Reader.

type IndexWriter

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

IndexWriter can be used to write keys to the "index" object.

func NewIndexWriter

func NewIndexWriter(w io.Writer) *IndexWriter

NewIndexWriter creates a new IndexWriter.

func (*IndexWriter) WriteKey

func (w *IndexWriter) WriteKey(k Key) error

WriteKey writes a Key to the io.WriteCloser.

type Key

type Key [sha256.Size]byte

Key is the identifier of a chunk of data.

func (Key) ToString

func (k Key) ToString() string

ToString returns the string representation of a key.

type KeyReader

type KeyReader interface {
	ReadKey() (Key, error)
}

KeyReader can be implemented by objects capable of reading Keys.

type KeyWriter

type KeyWriter interface {
	WriteKey(Key) error
}

KeyWriter can be implemented by objects capable of writing Keys.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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