resource

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package resource provides a resource definition.

Index

Constants

This section is empty.

Variables

View Source
var (
	KindNames = map[Kind]string{
		KindCPU:              "cpu",
		KindMemory:           "memory",
		KindSwap:             "swap",
		KindStorage:          "storage",
		KindEphemeralStorage: "ephemeral-storage",
		KindNetwork:          "network",
		KindGPU:              "gpu",
		KindTPU:              "tpu",
	}
)
View Source
var (
	UnitNames = map[Unit]string{
		UnitBit:   "bit",
		UnitByte:  "byte",
		UnitHertz: "hertz",
	}
)

Functions

This section is empty.

Types

type Kind

type Kind uint8

Kind represents the kind of a resource

const (
	KindInvalid Kind = iota
	KindCPU
	KindMemory
	KindSwap
	KindStorage
	KindEphemeralStorage
	KindNetwork
	KindGPU
	KindTPU
)

func ParseKind

func ParseKind(value string) Kind

ParseKind parses Kind from string.

func (Kind) Bytes

func (k Kind) Bytes() []byte

Bytes returns the Kind as a []byte.

func (Kind) MarshalJSON

func (k Kind) MarshalJSON() ([]byte, error)

MarshalJSON outputs the Kind as a json.

func (Kind) String

func (k Kind) String() string

String outputs the Kind as a string.

func (*Kind) UnmarshalJSON

func (k *Kind) UnmarshalJSON(data []byte) error

UnmarshalJSON parses Kind from json.

func (Kind) Validate

func (k Kind) Validate() bool

Validate returns true if the Kind is valid.

type Quantity

type Quantity struct {
	Unit Unit   `json:"unit"`
	Val  uint64 `json:"val"`
}

Quantity represents a quantity

type Resource

type Resource struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Kind        Kind           `json:"kind"`
	Quantity    Quantity       `json:"quantity"`
	Attributes  types.Map[any] `json:"attributes"`
}

Resource is a struct that represents a resource for naming can be used semantic conventions (https://opentelemetry.io/docs/specs/semconv/)

type Unit

type Unit uint8

Unit represents the unit of a resource

const (
	UnitInvalid Unit = iota
	UnitBit
	UnitByte
	UnitHertz
)

func ParseUnit

func ParseUnit(value string) Unit

ParseUnit parses Unit from string.

func (Unit) Bytes

func (u Unit) Bytes() []byte

Bytes returns the Unit as a []byte.

func (Unit) MarshalJSON

func (u Unit) MarshalJSON() ([]byte, error)

MarshalJSON outputs the Unit as a json.

func (Unit) String

func (u Unit) String() string

String outputs the Unit as a string.

func (*Unit) UnmarshalJSON

func (u *Unit) UnmarshalJSON(data []byte) error

UnmarshalJSON parses Unit from json.

func (Unit) Validate

func (u Unit) Validate() bool

Validate returns true if the Unit is valid.

Jump to

Keyboard shortcuts

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