util

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AmendTaskExtraAttr

func AmendTaskExtraAttr(origin, new string) string

Merge two JSON strings. If there are overlapping keys, values from the second JSON take precedence.

func CheckFileLength

func CheckFileLength(filepath string) error

CheckFileLength check if the file length is within the limit.

func CheckMailType

func CheckMailType(mailtype string) bool

func CheckNameValid

func CheckNameValid(name string) bool

func CheckNodeList

func CheckNodeList(nodeStr string) bool

CheckNodeList check if the node list is comma separated node names. The node name should contain only letters and numbers, and start with a letter, end with a number.

func CheckTaskArgs

func CheckTaskArgs(task *protos.TaskToCtld) error

func CheckTaskExtraAttr

func CheckTaskExtraAttr(attr string) bool

func ErrMsg

func ErrMsg(err_code protos.ErrCode) string

func FoundFirstNumberWithoutBrackets

func FoundFirstNumberWithoutBrackets(input string) (int, int, bool)

func HostNameListToStr

func HostNameListToStr(hostList []string) string

func HostNameListToStr_

func HostNameListToStr_(hostList []string) ([]string, bool)

func InvalidDuration

func InvalidDuration() *durationpb.Duration

func ParseDuration

func ParseDuration(time string, duration *durationpb.Duration) bool

func ParseFloatWithPrecision

func ParseFloatWithPrecision(val string, decimalPlaces int) (float64, error)

Parses a string containing a float number with a given precision.

func ParseGres

func ParseGres(gres string) *protos.DeviceMap

func ParseHostList

func ParseHostList(hostStr string) ([]string, bool)

func ParseInRamTaskStatusList

func ParseInRamTaskStatusList(statesStr string) ([]protos.TaskStatus, error)

func ParseInterval

func ParseInterval(interval string, intervalpb *protos.TimeInterval) (err error)

func ParseJobIdList

func ParseJobIdList(jobIds string, splitStr string) ([]uint32, error)

func ParseMemStringAsByte

func ParseMemStringAsByte(mem string) (uint64, error)

func ParseNodeList

func ParseNodeList(nodeStr string) ([]string, bool)

func ParseStringParamList

func ParseStringParamList(parameters string, splitStr string) ([]string, error)

func ParseTaskStatusList

func ParseTaskStatusList(statesStr string) ([]protos.TaskStatus, error)

func ParseTaskStatusName

func ParseTaskStatusName(state string) (protos.TaskStatus, error)

func ParseTime

func ParseTime(ts string) (time.Time, error)

func RemoveBracketsWithoutDashOrComma

func RemoveBracketsWithoutDashOrComma(input string) string

func SecondTimeFormat

func SecondTimeFormat(second int64) string

Types

type CraneCmdError

type CraneCmdError = int
const (
	ErrorSuccess       CraneCmdError = 0
	ErrorGeneric       CraneCmdError = 1
	ErrorCmdArg        CraneCmdError = 2
	ErrorNetwork       CraneCmdError = 3
	ErrorBackend       CraneCmdError = 4
	ErrorInvalidFormat CraneCmdError = 5
)

general

Jump to

Keyboard shortcuts

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