Files
kopia/cli/storage_providers.go
Jarek Kowalski 62edab618f throtting: implemented a Throttler based on token bucket and configur… (#1512)
* throtting: implemented a Throttler based on token bucket and configurable window.

* cli: rewired throttle options to use common Limits structure and helpers

The JSON is backwards compatible.

* blob: remove explicit throttling from gcs,s3,b2 & azure

* cleanup: removed internal/throttle

* repo: add throttling wrapper around storage at the repository level

* throttling: expose APIs to get limits and add validation

* server: expose API to get/set throttle in a running server

* pr feedback
2021-11-16 07:39:26 -08:00

44 lines
1.7 KiB
Go

package cli
import (
"context"
"github.com/alecthomas/kingpin"
"github.com/kopia/kopia/repo/blob"
"github.com/kopia/kopia/repo/blob/throttling"
)
type storageProviderServices interface {
setPasswordFromToken(pwd string)
}
type storageFlags interface {
setup(sps storageProviderServices, cmd *kingpin.CmdClause)
connect(ctx context.Context, isCreate bool, formatVersion int) (blob.Storage, error)
}
type storageProvider struct {
name string
description string
newFlags func() storageFlags
}
var storageProviders = []storageProvider{
{"from-config", "the provided configuration file", func() storageFlags { return &storageFromConfigFlags{} }},
{"azure", "an Azure blob storage", func() storageFlags { return &storageAzureFlags{} }},
{"b2", "a B2 bucket", func() storageFlags { return &storageB2Flags{} }},
{"filesystem", "a filesystem", func() storageFlags { return &storageFilesystemFlags{} }},
{"gcs", "a Google Cloud Storage bucket", func() storageFlags { return &storageGCSFlags{} }},
{"rclone", "a rclone-based provided", func() storageFlags { return &storageRcloneFlags{} }},
{"s3", "an S3 bucket", func() storageFlags { return &storageS3Flags{} }},
{"sftp", "an SFTP storage", func() storageFlags { return &storageSFTPFlags{} }},
{"webdav", "a WebDAV storage", func() storageFlags { return &storageWebDAVFlags{} }},
}
func commonThrottlingFlags(cmd *kingpin.CmdClause, limits *throttling.Limits) {
cmd.Flag("max-download-speed", "Limit the download speed.").PlaceHolder("BYTES_PER_SEC").FloatVar(&limits.DownloadBytesPerSecond)
cmd.Flag("max-upload-speed", "Limit the upload speed.").PlaceHolder("BYTES_PER_SEC").FloatVar(&limits.UploadBytesPerSecond)
}