transfer

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

Overview

Package transfer provides primitives for uploading and downloading datasets

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archiver

type Archiver interface {
	Index(fn func(k string) error) error
	Archive(ctx context.Context, path string, rep transferarchiver.Reporter, fn func(k string, r io.ReadSeeker, nbytes int64) error) error
	Unarchive(ctx context.Context, path string, rep transferarchiver.Reporter, fn func(k string, w io.WriterAt) error) error
}

Archiver allows archiving a directory

func CreateArchiver

func CreateArchiver(opts transferarchiver.ArchiverOptions) (Archiver, error)

CreateArchiver will creates one of the standard storews with the provided options

type DiscardReporter

type DiscardReporter struct{}

DiscardReporter is a reporter that discards

func NewDiscardReporter

func NewDiscardReporter() *DiscardReporter

NewDiscardReporter discards all progress reports

func (*DiscardReporter) HandledKey

func (r *DiscardReporter) HandledKey(key string)

HandledKey discards the information a key was handled

func (*DiscardReporter) StartArchivingProgress

func (r *DiscardReporter) StartArchivingProgress(label string, total int64) func(int64)

StartArchivingProgress is called when archiving has started and total size is known

func (*DiscardReporter) StartDownloadProgress

func (r *DiscardReporter) StartDownloadProgress(label string, total int64) io.Writer

StartDownloadProgress will start the download progress

func (*DiscardReporter) StartUnarchivingProgress

func (r *DiscardReporter) StartUnarchivingProgress(label string, total int64, rr io.Reader) io.Reader

func (*DiscardReporter) StartUploadProgress

func (r *DiscardReporter) StartUploadProgress(label string, total int64, rr io.Reader) io.Reader

StartUploadProgress is called when upload has started while total size is known

func (*DiscardReporter) StopArchivingProgress

func (r *DiscardReporter) StopArchivingProgress()

StopArchivingProgress is called when archiving has stoppped

func (*DiscardReporter) StopDownloadProgress

func (r *DiscardReporter) StopDownloadProgress()

StopDownloadProgress will stop the download progress

func (*DiscardReporter) StopUnarchivingProgress

func (r *DiscardReporter) StopUnarchivingProgress()

func (*DiscardReporter) StopUploadProgress

func (r *DiscardReporter) StopUploadProgress()

StopUploadProgress is called when uploading has stopped

type Handle

type Handle interface {
	io.Closer
	Name() string
	Clear(ctx context.Context, reporter Reporter) error
	Push(ctx context.Context, fromPath string, rep Reporter) error
	Pull(ctx context.Context, toPath string, rep Reporter) error
}

A Handle provides interactions with a dataset

type HandleDelegate

type HandleDelegate interface {
	PostClean(ctx context.Context) error             //eg, set size to
	PostPush(ctx context.Context, size uint64) error //eg, set new size
	PostPull(ctx context.Context) error
	PostClose() error //eg release the lock
}

HandleDelegate allows customization of lifecycle events, these events can be handled inside the lock of the handle

type KubeManager

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

KubeManager is a dataset manager that uses Kubernetes as its metadata store and locking service

func NewKubeManager

func NewKubeManager(kube *svc.Kube) (mgr *KubeManager, err error)

NewKubeManager creates a transferManager that uses our kubevisor implementation

func (*KubeManager) Create

func (mgr *KubeManager) Create(ctx context.Context, name string, sto transferstore.StoreOptions, ato transferarchiver.ArchiverOptions) (h Handle, err error)

Create a dataset with provided name and return a handle to it, dataset must not yet exist

func (*KubeManager) Info

func (mgr *KubeManager) Info(ctx context.Context, name string) (size uint64, err error)

Info (re)fetches dataset info from the manager

func (*KubeManager) Open

func (mgr *KubeManager) Open(ctx context.Context, name string) (Handle, error)

Open an existing dataset and return a handle to it, dataset must exist

func (*KubeManager) Remove

func (mgr *KubeManager) Remove(ctx context.Context, name string) error

Remove an existing dataset, dataset must exist

type Manager

type Manager interface {
	Create(ctx context.Context, name string, sti transferstore.StoreOptions, sto transferarchiver.ArchiverOptions) (Handle, error) //must not exist, name is unique, claims dataset handle
	Open(ctx context.Context, name string) (Handle, error)                                                                         //must exist, claims dataset handle
	Remove(ctx context.Context, name string) error
	Info(ctx context.Context, name string) (size uint64, err error)
}

Manager provides access to Transfer handles, this allows parallel access to datasets from multiple clients

type Reporter

type Reporter interface {
	transferarchiver.Reporter

	HandledKey(key string)
	StartUploadProgress(label string, total int64, rr io.Reader) io.Reader
	StopUploadProgress()
	StartDownloadProgress(label string, total int64) io.Writer
	StopDownloadProgress()
}

Reporter handles progress reporting

type StdHandle

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

StdHandle provides a standard implementation for handling datasets

func CreateStdHandle

func CreateStdHandle(name string, store Store, a Archiver, del HandleDelegate) (*StdHandle, error)

CreateStdHandle sets up a standard implementation of the handle

func (*StdHandle) Clear

func (h *StdHandle) Clear(ctx context.Context, reporter Reporter) (err error)

Clear removes all objects related to a dataset

func (*StdHandle) Close

func (h *StdHandle) Close() (err error)

Close the handle performing any cleanup logic

func (*StdHandle) Name

func (h *StdHandle) Name() string

Name returns the name

func (*StdHandle) Pull

func (h *StdHandle) Pull(ctx context.Context, toPath string, rep Reporter) (err error)

Pull content from the store to the local filesystem

func (*StdHandle) Push

func (h *StdHandle) Push(ctx context.Context, fromPath string, rep Reporter) (err error)

Push pushes new content from a local filesystem

type Store

type Store interface {
	Head(ctx context.Context, k string) (size int64, err error)
	Get(ctx context.Context, key string, w io.WriterAt) error
	Put(ctx context.Context, key string, r io.ReadSeeker) error
	Del(ctx context.Context, key string) error
}

Store provides an object storage interface

func CreateStore

func CreateStore(opts transferstore.StoreOptions) (Store, error)

CreateStore will creates of the standard stores based on the store options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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