node

package
v0.0.0-...-ca37748 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const ActionGroupDefaultDefault = 0

Default number of actions that do not specify an action group

View Source
const ActionGroupTotalDefault = 100

By default number of concurrent actions

View Source
const QuickPollThreshold int = 25
View Source
const StreamTeardownDelay = 250 * time.Millisecond

Variables

This section is empty.

Functions

func GetCliCommand

func GetCliCommand() *cli.Command

func MonitorThread

func MonitorThread(node *Node, ctx context.Context, logger *slog.Logger, done func())

func NServerThread

func NServerThread(node *Node, ctx context.Context, logger *slog.Logger, done func())

func NodeStateThread

func NodeStateThread(n *Node, ctx context.Context, logger *slog.Logger, done func())

Types

type Action

type Action struct {
	Name        string                    `yaml:"name" json:"name"`
	Params      []string                  `yaml:"params" json:"params"`
	Commands    []string                  `yaml:"commands" json:"commands"`
	Description string                    `yaml:"description" json:"description"`
	ResourceReq resources.ResourceRequest `yaml:"resources" json:"resource"`
}

func (Action) BuildCommands

func (a Action) BuildCommands(params any) ([]string, error)

func (Action) Run

func (a Action) Run(params any) ([]string, error)

func (Action) RunStreamed

func (a Action) RunStreamed(streamDest string, params any, logger *slog.Logger) error

type AdHocAction

type AdHocAction struct {
	ActionDef Action `yaml:"action" json:"action"`
}

type Node

type Node struct {
	Name        string
	ServerPort  int
	DataDir     string
	Data        map[string]map[string]interface{}
	ActionsPath string
	Actions     map[string]*Action
	OrchAddr    string

	ArbitraryActions bool
	LogFile          string
	MaxNumActions    int
	CertPath         string
	Resources        *resources.ResourceManager
	// contains filtered or unexported fields
}

func (*Node) ReloadActions

func (node *Node) ReloadActions(path string) error

func (*Node) Run

func (node *Node) Run(logger *slog.Logger) (err error)

func (*Node) RunAction

func (node *Node) RunAction(action *Action, streamDest string, params map[string]string, logger *slog.Logger) (out string, semOk bool, err error)

type NodeCommState

type NodeCommState string
const (
	Polling       NodeCommState = "polling"
	QuickPolling  NodeCommState = "quick-polling"
	Registered    NodeCommState = "registered"
	Disconnecting NodeCommState = "disconnecting"
	Disconnected  NodeCommState = "disconnected"
	Idle          NodeCommState = "idle"
)

type NodeConfig

type NodeConfig struct {
	Name             string             `yaml:"name"`
	Port             int                `yaml:"port"`
	Host             string             `yaml:"host"`
	Orchestrator     string             `yaml:"orchestrator"`
	Data             string             `yaml:"data"`
	Log              string             `yaml:"log"`
	LogLevel         string             `yaml:"log-level"`
	CertPath         string             `yaml:"cert-path"`
	ArbitraryActions bool               `yaml:"arbitrary-actions"`
	Actions          map[string]*Action `yaml:"actions"`
	ResourceGroups   map[string]int64   `yaml:"resource-groups"`
}

func NewNodeConfig

func NewNodeConfig() *NodeConfig

func (*NodeConfig) ReadConfig

func (c *NodeConfig) ReadConfig(path string) error

type NodeState

type NodeState struct {
	// contains filtered or unexported fields
}

func (*NodeState) ChangeState

func (ns *NodeState) ChangeState(state NodeCommState)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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