util

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogInfo        = "log.info"
	BlockSizeLinux = 512

	MaxLogFileSize         = "maxLogFileSize"
	RetentionPeriod        = "retentionPeriod"
	MaxBackups             = "maxBackups"
	DefaultLogFileSize     = 100
	DefaultRetentionPeriod = 180
	DefaultMaxBackups      = 5
)

Variables

View Source
var (
	MaximumVolumeNameSize = 64

	Logrotator *lumberjack.Logger
)

Functions

func ChainContainsSnapshot added in v1.12.1

func ChainContainsSnapshot(chain []string, snapshot string) bool

func CheckReplicationFactor

func CheckReplicationFactor() int

CheckReplicationFactor returns the value of env var REPLICATION_FACTOR if it has not been set, then it returns 0.

func Contains

func Contains(arr []string, val string) bool

func ConvertHumanReadable

func ConvertHumanReadable(b int64) string

func DuplicateDevice

func DuplicateDevice(src, dest string) error

func Filter

func Filter(list []string, check func(string) bool) []string

func FilteredLoggingHandler

func FilteredLoggingHandler(filteredPaths map[string]struct{}, writer io.Writer, router http.Handler) http.Handler

func GetFileActualSize

func GetFileActualSize(file string) int64

func GetReadTimeout

func GetReadTimeout() time.Duration

GetReadTimeout gets the read timeout value from the env

func GetWriteTimeout

func GetWriteTimeout() time.Duration

GetWriteTimeout gets the write timeout value from the env

func LogRotate

func LogRotate(dir string) error

func Now

func Now() string

func ParseAddresses

func ParseAddresses(address string) (string, string, string, error)

ParseAddresses returns the base address and two with subsequent ports

func RemoveDevice

func RemoveDevice(dev string) error

func SetLogging

func SetLogging(dir string, lf LogToFile) error

func StartLoggingToFile

func StartLoggingToFile(dir string, lf LogToFile) error

func SyncDir

func SyncDir(dir string) error

SyncDir sync dir after creating or deleting the file the directory also needs to be synced in order to guarantee the file is visible across system crashes. See man page of fsync for more details.

func UUID

func UUID() string

func ValidVolumeName

func ValidVolumeName(name string) bool

func Volume2ISCSIName

func Volume2ISCSIName(name string) string

func WriteLogInfo

func WriteLogInfo(dir string, lf LogToFile) error

Types

type LogToFile

type LogToFile struct {
	Enable          bool `json:"enable"`
	MaxLogFileSize  int  `json:"maxlogfilesize"`
	RetentionPeriod int  `json:"retentionperiod"`
	MaxBackups      int  `json:"maxbackups"`
}

func ReadLogInfo

func ReadLogInfo(dir string) (LogToFile, error)

Jump to

Keyboard shortcuts

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