cli

package
v0.0.0-...-1bd3920 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoTracker = &nopTracker{}

NoTracker implements the ProgressTracker interface but does nothing.

Functions

func Download

func Download(
	ctx context.Context,
	sourcePkg *client.DatasetRef,
	sourcePath string,
	targetPath string,
	tracker ProgressTracker,
	concurrency int,
) error

Download all files under the sourcePath in the sourcePkg to the targetPath.

func FormatRate

func FormatRate(bytes int64, d time.Duration) string

FormatRate returns a string showing transfer rate in bytes-per-second.

func InterruptContext

func InterruptContext() context.Context

func Upload

func Upload(
	ctx context.Context,
	sourcePath string,
	targetPkg *client.DatasetRef,
	targetPath string,
	tracker ProgressTracker,
	concurrency int,
) error

Upload the sourcePath to the targetPath in the targetPkg.

func UploadStats

func UploadStats(directory string) (files, bytes int64, err error)

UploadStats finds the number of files and bytes that would be uploaded in a directory.

Types

type ProgressTracker

type ProgressTracker interface {
	Update(*ProgressUpdate)
	Close() error
}

ProgressTracker tracks the status of an operation.

type ProgressTrackerWithStatus

type ProgressTrackerWithStatus interface {
	ProgressTracker
	Status() *ProgressUpdate
}

ProgressTrackerWithStatus tracks the status of an operation and exposes the current status of the operation.

func BoundedTracker

func BoundedTracker(ctx context.Context, totalFiles, totalBytes int64) ProgressTrackerWithStatus

BoundedTracker shows the progress of an operation with a predefined size. Falls back to DefaultTracker if not in a terminal.

func DefaultTracker

func DefaultTracker() ProgressTrackerWithStatus

DefaultTracker prints a message on each update and on close.

func UnboundedTracker

func UnboundedTracker(ctx context.Context) ProgressTrackerWithStatus

UnboundedTracker shows the progress of an operation without a predefined size. Falls back to DefaultTracker if not in a terminal.

type ProgressUpdate

type ProgressUpdate struct {
	FilesPending, FilesWritten int64
	BytesPending, BytesWritten int64
}

ProgressUpdate contains deltas for each tracked value.

Jump to

Keyboard shortcuts

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