node

package
v2.0.7-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocatable

type Allocatable struct {
	NodeName   string    `json:"node_name" redis:"node_name"`
	Cpu        float64   `json:"cpu" redis:"cpu"`
	Disk       uint64    `json:"disk" redis:"disk"`
	Memory     uint64    `json:"memory" redis:"memory"`
	UpdateTime time.Time `json:"update_time" redis:"update_time"`
}

Allocatable available resources for node

func (*Allocatable) Key

func (a *Allocatable) Key() string

func (*Allocatable) Unmarshal

func (a *Allocatable) Unmarshal(data []byte) error

func (*Allocatable) Val

func (a *Allocatable) Val() string

type Capacity

type Capacity struct {
	NodeName    string      `json:"node_name" redis:"node_name"`
	Cpu         float64     `json:"cpu" redis:"cpu"`
	Disk        uint64      `json:"disk" redis:"disk"`
	Memory      uint64      `json:"memory" redis:"memory"` //byte
	CpuCors     int32       `json:"cpu_cores" redis:"cpu_cores"`
	CpuUsage    uint8       `json:"cpu_usage" redis:"cpu_usage"`
	MemoryUsage uint8       `json:"memory_usage" redis:"memory_usage"`
	UpdateTime  time.Time   `json:"update_time" redis:"update_time"`
	Allocatable Allocatable `json:"allocatable" redis:"allocatable"`
}

Capacity node capacity

func NewCapacity

func NewCapacity(nodeName string) *Capacity

New returns a new *Capacity

func (*Capacity) Key

func (c *Capacity) Key() string

func (*Capacity) Unmarshal

func (c *Capacity) Unmarshal(data []byte) error

func (*Capacity) Val

func (c *Capacity) Val() string

type CapacityMap

type CapacityMap map[string]*Capacity

func (*CapacityMap) Key

func (c *CapacityMap) Key() string

func (*CapacityMap) Unmarshal

func (c *CapacityMap) Unmarshal(data []byte) error

func (*CapacityMap) Val

func (c *CapacityMap) Val() string

type CapacityOption

type CapacityOption func(c *Capacity)

CapacityOption sets Capacity

type Condition

type Condition struct {
}

type Node

type Node struct {
	Name        string    `json:"name" redis:"name"`
	Role        Role      `json:"role" redis:"role"`
	IP          string    `json:"ip" redis:"ip"`
	Version     string    `json:"version" redis:"version"`
	CreateTime  time.Time `json:"create_time" redis:"create_time"`
	UpdateTime  time.Time `json:"update_time" redis:"update_time"`
	LastRunTime time.Time `json:"last_run_time" redis:"last_run_time"`
}

Node is node

func NewNode

func NewNode(name string) *Node

NewNode returns a new node

func (*Node) Key

func (s *Node) Key() string

Key generate etcd key

func (*Node) RegisterName

func (s *Node) RegisterName() string

func (*Node) Unmarshal

func (s *Node) Unmarshal(data []byte) error

Unmarshal generate from json data

func (*Node) Val

func (s *Node) Val() string

Val generate etcd val

type NodeOption

type NodeOption func(s model.Values)

NodeOption configure node

func WithNodeIP

func WithNodeIP(i net.IP) NodeOption

WithNodeIP sets node's ip

func WithNodeVersion

func WithNodeVersion(v string) NodeOption

WithNodeVersion sets node's version

type Role

type Role struct {
	Master bool `json:"master" redis:"master"`
	Admin  bool `json:"admin" redis:"admin"`
	Worker bool `json:"worker" redis:"worker"`
}

Role store struct

type Status

type Status struct {
	NodeName           string `json:"node_name" redis:"node_name"`
	Ready              bool   `json:"ready" redis:"ready"`
	NetworkUnavailable bool   `json:"network_unavailable" redis:"network_unavailable"`
	MemoryPressure     bool   `json:"memory_pressure" redis:"memory_pressure"`
	DiskPressure       bool   `json:"disk_pressure" redis:"disk_pressure"`
	CPUPressure        bool   `json:"cpu_pressure" redis:"cpu_pressure"`
}

Status node status

func New

func New(nodeName string) (s *Status)

New returns a status model

func (*Status) Key

func (s *Status) Key() string

func (*Status) Unmarshal

func (s *Status) Unmarshal(data []byte) error

func (*Status) Val

func (s *Status) Val() string

type StatusCondition

type StatusCondition = string

StatusCondition Status field name

const (
	ConReady              StatusCondition = "ready"
	ConNetworkUnavailable StatusCondition = "network_unavailable"
	ConMemoryPressure     StatusCondition = "memory_pressure"
	ConDiskPressure       StatusCondition = "disk_pressure"
	ConCPUPressure        StatusCondition = "cpu_pressure"
)

type StatusConditions

type StatusConditions = map[StatusCondition]bool

StatusConditions Status conditions

type StatusOption

type StatusOption func(s *Status)

StatusOption is function configure Status

func WithCPUPressure

func WithCPUPressure(b bool) StatusOption

WithCPUPressure sets status cpu

func WithMemoryPressure

func WithMemoryPressure(b bool) StatusOption

WithMemoryPressure sets status memory

func WithNetworkUnavailable

func WithNetworkUnavailable(b bool) StatusOption

WithNetworkUnavailable sets status network

func WithReady

func WithReady(b bool) StatusOption

WithReady sets status ready

Jump to

Keyboard shortcuts

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