Documentation
¶
Index ¶
- Constants
- func Batch(elements []string, batchSize int) [][]string
- func CloseToDeadline(ctx context.Context, tolerance time.Duration) bool
- func ContainsString(list []string, val string) bool
- func DeepCopy(a map[string]string) map[string]string
- func DeepCopyListUint32(list []uint32) []uint32
- func Equal(a map[string]string, b map[string]string) bool
- func Filter[T any](list []T, predicate func(val T) bool) []T
- func FilterKeys(a map[string]string, keys []string) map[string]string
- func FormatBinarySI(q int64) string
- func GetClusterAvailableCapacity(report *api.ClusterUsageReport) armadaresource.ComputeResources
- func GetClusterCapacity(report *api.ClusterUsageReport) armadaresource.ComputeResources
- func GetOrDefault(m map[string]float64, key string, def float64) float64
- func GetQueueReports(report *api.ClusterUsageReport) []*api.QueueReport
- func InverseMap[K comparable, V comparable](a map[K]V) map[V]K
- func MergeMaps(a map[string]string, b map[string]string) map[string]string
- func Min(a, b int) int
- func NewThreadsafeRand(seed int64) *rand.Rand
- func NewULID() string
- func PodSpecFromJob(job *api.Job) *v1.PodSpec
- func RemoveNullsFromJson(json []byte) []byte
- func RemoveNullsFromString(s string) string
- func StringFromUlid(id ulid.ULID) string
- func StringListToSet(list []string) map[string]bool
- func SubtractStringList(a []string, b []string) []string
- func SumReportClusterCapacity(reports map[string]*api.ClusterUsageReport) armadaresource.ComputeResources
- func Truncate(s string, max int) string
- func ULID() ulid.ULID
- type Clock
- type DefaultClock
- type DummyClock
- type LockedSource
- type StringInterner
- type UTCClock
Constants ¶
const MaxMessageLength = 2048
Variables ¶
This section is empty.
Functions ¶
func ContainsString ¶
func DeepCopyListUint32 ¶
func FormatBinarySI ¶
func GetClusterAvailableCapacity ¶
func GetClusterAvailableCapacity(report *api.ClusterUsageReport) armadaresource.ComputeResources
GetClusterAvailableCapacity returns the total resource to be shared amongst queues. This is the total capacity available to armada on schedulable nodes + the capacity currently in use on unschedulable nodes.
func GetClusterCapacity ¶
func GetClusterCapacity(report *api.ClusterUsageReport) armadaresource.ComputeResources
GetClusterCapacity returns the total capacity on all nodes on a cluster, even if they are unschedulable.
func GetQueueReports ¶
func GetQueueReports(report *api.ClusterUsageReport) []*api.QueueReport
func InverseMap ¶
func InverseMap[K comparable, V comparable](a map[K]V) map[V]K
InverseMap creates a new map where each key: value pair is swapped If the same value is present multiple times, a random one will be selected (depending on map key-value iteration)
func NewThreadsafeRand ¶
NewThreadsafeRand Returns a *rand.Rand that is safe to share across multiple goroutines
func NewULID ¶
func NewULID() string
NewULID returns a new ULID for the current time generated from a global RNG. The ULID is returned as a string converted to lower-case to ensure it is a valid DNS subdomain name; see https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names
func RemoveNullsFromJson ¶
func RemoveNullsFromString ¶
func StringFromUlid ¶
StringFromUlid returns a string representation of a proto UUID. Because Kubernetes requires ids to be valid DNS subdomain names, the string is returned in lower-case; see https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names
func StringListToSet ¶
func SubtractStringList ¶
func SumReportClusterCapacity ¶
func SumReportClusterCapacity(reports map[string]*api.ClusterUsageReport) armadaresource.ComputeResources
Types ¶
type DefaultClock ¶
type DefaultClock struct{}
func (*DefaultClock) Now ¶
func (c *DefaultClock) Now() time.Time
type DummyClock ¶
func (*DummyClock) Now ¶
func (c *DummyClock) Now() time.Time
type LockedSource ¶
type LockedSource struct {
// contains filtered or unexported fields
}
LockedSource is a random source that is uses a mutex to ensure it is threadsafe
func (*LockedSource) Int63 ¶
func (r *LockedSource) Int63() (n int64)
func (*LockedSource) Seed ¶
func (r *LockedSource) Seed(seed int64)
type StringInterner ¶ added in v0.3.47
type StringInterner struct {
// contains filtered or unexported fields
}
StringInterner allows strings with equal values but different backing arrays to be deduplicated This is useful in Armada where common strings are often used across jobs (e.g. jobset, queue) and so deduplication can help save memory. The Interner is backed by an LRU so that only the most recently interned strings are kept. Note that this probably isn't the most efficient implementation (eg see https://github.com/josharian/intern which abuses sync.pool) but this should be reliable and performance more than good enough for Armada use cases
func NewStringInterner ¶ added in v0.3.47
func NewStringInterner(cacheSize uint32) (*StringInterner, error)
NewStringInterner will allocate an Interner backed by an LRU limited to the provided size
func (*StringInterner) Intern ¶ added in v0.3.47
func (i *StringInterner) Intern(s string) string
Intern ensures the string is cached and returns the cached string