File: names.go

package info (click to toggle)
golang-github-mesos-mesos-go 0.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 11,724 kB
  • sloc: makefile: 163
file content (30 lines) | stat: -rw-r--r-- 676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package resources

import (
	"sort"

	"github.com/mesos/mesos-go/api/v1/lib"
)

type (
	Name  string
	Names []Name
)

const (
	NameCPUs  = Name("cpus")
	NameDisk  = Name("disk")
	NameGPUs  = Name("gpus")
	NameMem   = Name("mem")
	NamePorts = Name("ports")
)

// String implements fmt.Stringer
func (n Name) String() string                { return string(n) }
func (n Name) Filter(r *mesos.Resource) bool { return r != nil && r.Name == string(n) }

func (ns Names) Len() int           { return len(ns) }
func (ns Names) Less(i, j int) bool { return ns[i] < ns[j] }
func (ns Names) Swap(i, j int)      { ns[i], ns[j] = ns[j], ns[i] }

func (ns Names) Sort() { sort.Stable(ns) }