Client for accessing Varasto server



View Source
const (
	BackgroundUploaderConcurrency = 3


This section is empty.


func BlobIdxFromOffset

func BlobIdxFromOffset(offset int64) (int, int64)

func Commit

func Commit(
	changeset stotypes.CollectionChangeset,
	collectionId string,
	clientConfig ClientConfig,
) (*stotypes.Collection, error)

func ConfigFilePath

func ConfigFilePath() (string, error)

func DownloadChunk

func DownloadChunk(ctx context.Context, ref stotypes.BlobRef, collectionId string, clientConfig ClientConfig) (io.Reader, func(), error)

verifies chunk integrity on-the-fly

func DownloadOneFile

func DownloadOneFile(
	ctx context.Context,
	file stotypes.File,
	collectionId string,
	destination io.Writer,
	config ClientConfig,
) error

func Entrypoints

func Entrypoints() []*cobra.Command

func FetchCollectionMetadata

func FetchCollectionMetadata(clientConfig ClientConfig, id string) (*stotypes.Collection, error)

func NewBackgroundUploader

func NewBackgroundUploader(
	ctx context.Context,
	n int,
	clientConfig ClientConfig,
	uploadProgress UploadProgressListener,
) *backgroundUploader

func NewBlobDiscoveredAttrs

func NewBlobDiscoveredAttrs(
	ref stotypes.BlobRef,
	collectionId string,
	content []byte,
	maybeCompressible bool,
	filePath string,
	size int64,
) blobDiscoveredAttrs

func NewWorkdirLocation

func NewWorkdirLocation(path string) (*workdirLocation, error)

func ScanAndDiscoverBlobs

func ScanAndDiscoverBlobs(
	ctx context.Context,
	relativePath string,
	file io.Reader,
	totalSize int64,
	creationTime time.Time,
	modifiedTime time.Time,
	collectionId string,
	bdl BlobDiscoveredListener,
) (*stotypes.File, error)

- for when you don't have a file, but you have a stream - totalsize is used for progress calculation, but if you're not using progress UI you can set it to 0

func UploadBlob

func UploadBlob(
	ctx context.Context,
	blobRef stotypes.BlobRef,
	content io.Reader,
	collectionId string,
	maybeCompressible bool,
	clientConfig ClientConfig,
) error

func WriteConfig

func WriteConfig(conf *ClientConfig) error

func WriteConfigWithPath

func WriteConfigWithPath(conf *ClientConfig, confPath string) error

used by bootstrap


type BlobDiscoveredListener

type BlobDiscoveredListener interface {
	// listener (like backgroundUploader) will inform its producer (blob discoverer) that
	// uploads are erroring, to request that blob discovery should be stopped
	CancelCh() chan interface{}

func NewBlobDiscoveredNoopListener

func NewBlobDiscoveredNoopListener() BlobDiscoveredListener

new blob? didn't do nuffin

type BupManifest

type BupManifest struct {
	ChangesetId string              `json:"changeset_id"`
	Collection  stotypes.Collection `json:"collection"` // snapshot at time of server fetch

type ClientConfig

type ClientConfig struct {
	ServerAddr                string `json:"server_addr"` // example: "https://localhost"
	AuthToken                 string `json:"auth_token"`
	FuseMountPath             string `json:"fuse_mount_path"`
	TlsInsecureSkipValidation bool   `json:"tls_insecure_skip_validation"`

func ReadConfig

func ReadConfig() (*ClientConfig, error)

func (*ClientConfig) CommandClient

func (c *ClientConfig) CommandClient() *httpcommandclient.Client

func (*ClientConfig) HttpClient

func (c *ClientConfig) HttpClient() *http.Client

func (*ClientConfig) UrlBuilder

type UploadProgressListener

type UploadProgressListener interface {
	// it is not safe to call ReportUploadProgress after calling Close.
	// returns only after resources (like termbox) used by listener are freed.

func NewNullUploadProgressListener

func NewNullUploadProgressListener() UploadProgressListener