common

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Kib    int64 = 1024
	Mib    int64 = Kib * 1024
	Gib    int64 = Mib * 1024
	Gib100 int64 = Gib * 100
	Tib    int64 = Gib * 1024
	Tib100 int64 = Tib * 100
)
View Source
const (
	FileSystemExt3    string = "ext3"
	FileSystemExt4    string = "ext4"
	FileSystemXfs     string = "xfs"
	DefaultFileSystem string = FileSystemExt4
)
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05"
View Source
const Int64Max = int64(^uint64(0) >> 1)
View Source
const (
	OperationPendingFmt = "already an operation for the specified resource %s"
)

Variables

This section is empty.

Functions

func ByteCeilToGib

func ByteCeilToGib(nByte int64) int

ByteCeilToGib Convert Byte to Gib

func EntryFunction

func EntryFunction(functionName string) (info string, hash string)

EntryFunction print timestamps

func ExitFunction

func ExitFunction(functionName, hash string) (info string)

ExitFunction print timestamps

func GenerateHashInEightBytes

func GenerateHashInEightBytes(input string) string

GenerateRandIdSuffix generates a random resource id.

func GetRequestSizeBytes

func GetRequestSizeBytes(capRange *csi.CapacityRange) (int64, error)

GetRequestSizeBytes get minimal required bytes and not exceed limit bytes.

func GibToByte

func GibToByte(nGib int) int64

GibToByte Convert GiB to Byte

func IsValidCapacityBytes

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

Valid capacity bytes in capacity range

func NewSafeMounter

func NewSafeMounter() *mount.SafeFormatAndMount

func ParseEndpoint

func ParseEndpoint(ep string) (string, string, error)

func RetryOnError

func RetryOnError(backoff wait.Backoff, fn func() error) error

Retry on any error

Types

type NonBlockingGRPCServer

type NonBlockingGRPCServer interface {
	// Start services at the endpoint
	Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer)
	// Waits for the service to stop
	Wait()
	// Stops the service gracefully
	Stop()
	// Stops the service forcefully
	ForceStop()
}

Defines Non blocking GRPC server interfaces

func NewNonBlockingGRPCServer

func NewNonBlockingGRPCServer() NonBlockingGRPCServer

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.

type RetryLimiter added in v1.1.1

type RetryLimiter interface {
	Add(id string)
	Try(id string) bool
	GetMaxRetryTimes() int
	GetCurrentRetryTimes(id string) int
}

func NewRetryLimiter added in v1.1.1

func NewRetryLimiter(maxRetry int) RetryLimiter

Jump to

Keyboard shortcuts

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