util

package
v0.5.25 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: Apache-2.0, BSD-3-Clause, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = uint64(1024)
	MB = 1024 * KB
	GB = 1024 * MB
	TB = 1024 * GB

	KBF = float64(KB)
	MBF = float64(MB)
	GBF = float64(GB)
	TBF = float64(TB)
)

/////////////////////////////////////////////////////////////////

Storage sizes -- print and scan bytes, and sizes suffixed with KB,MB,GB,TB

////////////////////////////////////////////////////////////////

View Source
const BufferQCapacity = 50

BufferQCapacity number of pre-allocated buffers

View Source
const LargeBlockAPIVersion = "2016-05-31"

LargeBlockAPIVersion API version that supports large block blobs

View Source
const LargeBlockSizeMax = 100 * MB

LargeBlockSizeMax maximum block size

View Source
const MaxBlockCount = 50000 // no more than this many blob blocks permitted

MaxBlockCount the maximum number of blocks in a blob

View Source
const MiByte = 1048576

MiByte bytes in one MiB

Variables

View Source
var HTTPClientTimeout = 600

HTTPClientTimeout HTTP timeout of the HTTP client used by the storage client.

View Source
var Verbose = false

Verbose mode active?

Functions

func AskUser

func AskUser(question string) bool

AskUser places a yes/no question to the user provided by the stdin

func BoolVarAlias

func BoolVarAlias(varPtr *bool, shortflag string, longflag string, defaultVal bool, description string)

BoolVarAlias bool commandline option

func ByteCountFromSizeString

func ByteCountFromSizeString(sizeStr string) (uint64, error)

ByteCountFromSizeString accepts byte count, or integer suffixed with B, KB, MB, GB. ... Return the corresponding count of bytes.

func CleanUncommittedBlocks

func CleanUncommittedBlocks(client *storage.BlobStorageClient, container string, blobName string) error

CleanUncommittedBlocks clears uncommitted blocks if an existing blob does not exists.

func CreateContainerIfNotExists

func CreateContainerIfNotExists(container string, accountName string, accountKey string)

CreateContainerIfNotExists Creates a new container if doesn't exists. Validates the name of the container.

func GetBlobStorageClient

func GetBlobStorageClient(accountName string, accountKey string) storage.BlobStorageClient

GetBlobStorageClient gets a storage client with support for larg block blobs

func GetBlobStorageClientWithNewHTTPClient added in v0.5.12

func GetBlobStorageClientWithNewHTTPClient(accountName string, accountKey string) storage.BlobStorageClient

GetBlobStorageClientWithNewHTTPClient gets a storage client with a new instace of the HTTP client.

func GetBlobStorageClientWithSASToken

func GetBlobStorageClientWithSASToken(accountName string, sasToken string) storage.BlobStorageClient

GetBlobStorageClientWithSASToken gets a storage client with support for large block blobs

func GetFileNameFromURL

func GetFileNameFromURL(sourceURI string) (string, error)

GetFileNameFromURL returns last part of URL (filename)

func GetUserAgentInfo added in v0.5.22

func GetUserAgentInfo() (string, error)

GetUserAgentInfo TODO

func IntVarAlias

func IntVarAlias(varPtr *int, shortflag string, longflag string, defaultVal int, description string)

IntVarAlias int commandline option

func NewHTTPClient

func NewHTTPClient() *http.Client

NewHTTPClient creates a shared HTTP client with the configured timeout and MaxIdleConnsPerHost = 50, keep alive dialer.

func PrintSize

func PrintSize(bytes uint64) string

PrintSize formats a string with a compact respresentation of a byte count

func PrintUsageDefaults

func PrintUsageDefaults(shortflag string, longflag string, defaultVal string, description string)

PrintUsageDefaults print commandline usage options

func PrintfIfDebug added in v0.5.12

func PrintfIfDebug(format string, values ...interface{})

PrintfIfDebug TODO

func RetriableOperation

func RetriableOperation(operation func(r int) error) (duration time.Duration, startTime time.Time, numOfRetries int)

RetriableOperation executes a function, retrying up to "retryLimit" times and waiting "retrySleepDuration" between attempts

func SetUserAgentInfo added in v0.5.22

func SetUserAgentInfo(programVersion string)

SetUserAgentInfo TODO

func StringListVarAlias

func StringListVarAlias(varPtr *ListFlag, shortflag string, longflag string, defaultVal string, description string)

StringListVarAlias string commandline option

func StringVarAlias

func StringVarAlias(varPtr *string, shortflag string, longflag string, defaultVal string, description string)

StringVarAlias string commandline option

func Uint64VarAlias

func Uint64VarAlias(varPtr *uint64, shortflag string, longflag string, defaultVal uint64, description string)

Uint64VarAlias uint64 commandline option

Types

type ListFlag

type ListFlag []string

ListFlag represents a multivalue flag

func (*ListFlag) Set

func (lst *ListFlag) Set(value string) error

Set adds a new value to the values list

func (*ListFlag) String

func (lst *ListFlag) String() string

String joints all values of the flag

Jump to

Keyboard shortcuts

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