common

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hash = "Hash"

	Gib = 1 << 30
)
View Source
const (
	OperationPendingFmt = "already an operation for the specified resource %s"
)

Variables

This section is empty.

Functions

func ContextWithHash

func ContextWithHash(ctx context.Context, hash string) context.Context

ContextWithHash return context with hash value

func DefaultRetryErrorFunc added in v1.2.0

func DefaultRetryErrorFunc(e error) bool

func ExecCommand

func ExecCommand(command string, args []string) ([]byte, error)

ExecCommand Return cases: normal output, nil: normal output

error logs,		error:	command execute error

func GenerateHashInEightBytes

func GenerateHashInEightBytes(input string) string

GenerateRandIdSuffix generates a random resource id.

func GetContextHash

func GetContextHash(ctx context.Context) string

GetContextHash return hash of context noinspection GoUnusedExportedFunction

func IsValidCapacityBytes

func IsValidCapacityBytes(cur int64, capRange *csi.CapacityRange) bool

Valid capacity bytes in capacity range

func ParseIntToDec

func ParseIntToDec(hex string) (dec string)

ParseIntToDec convert number string to decimal number string

Types

type ResourceLocks

type ResourceLocks struct {
	// contains filtered or unexported fields
}

ResourceLocks implements a map with atomic operations. It stores a set of all resource IDs with an ongoing operation.

func NewResourceLocks

func NewResourceLocks() *ResourceLocks

func (*ResourceLocks) Release

func (lock *ResourceLocks) Release(resourceID string)

func (*ResourceLocks) TryAcquire

func (lock *ResourceLocks) TryAcquire(resourceID string) bool

TryAcquire tries to acquire the lock for operating on resourceID and returns true if successful. If another operation is already using resourceID, returns false.

Jump to

Keyboard shortcuts

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