v0.0.0-...-ea0be71 Latest Latest

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 35 Imported by: 0



Client for accessing Varasto server



View Source
const (
	BackgroundUploaderConcurrency = 3
View Source
const (
	LocalStatefile = ".varasto"


This section is empty.


func BlobIdxFromOffset

func BlobIdxFromOffset(offset int64) (int, int64)

func ConfigFilePath

func ConfigFilePath() (string, error)

returns ~/.config/varasto/varastoclient-config.json

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 Entrypoints

func Entrypoints() []*cobra.Command

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 Client

type Client struct {
	// contains filtered or unexported fields

func New

func New(conf ClientConfig) *Client

func (*Client) Commit

func (c *Client) Commit(
	ctx context.Context,
	collectionId string,
	changeset stotypes.CollectionChangeset,
) (*stotypes.Collection, error)

func (*Client) Config

func (c *Client) Config() ClientConfig

func (*Client) DownloadOneFile

func (c *Client) DownloadOneFile(
	ctx context.Context,
	collectionId string,
	file stotypes.File,
	destination io.Writer,
) error

func (*Client) FetchCollectionMetadata

func (c *Client) FetchCollectionMetadata(
	ctx context.Context,
	id string,
) (*stotypes.Collection, error)

if collection doesn't exist: os.IsNotExist(err) will return true

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) Client

func (c *ClientConfig) Client() *Client

TODO: this should be temporary

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

Jump to

Keyboard shortcuts

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