agent

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoopEvent = iota
	IdentifyEvent
	IdentifyConfirmEvent
	CriticalEvent
	CriticalResetEvent
	EdgeButtonEvent
)

Variables

This section is empty.

Functions

func NewGrpcServiceFor

func NewGrpcServiceFor(agent ComputeBladeAgent) *agentGrpcService

NewGrpcServiceFor creates a new gRPC service for a given agent

Types

type ComputeBladeAgent

type ComputeBladeAgent interface {
	// Run dispatches the agent and blocks until the context is canceled or an error occurs
	Run(ctx context.Context) error
	// EmitEvent emits an event to the agent
	EmitEvent(ctx context.Context, event Event) error
	// SetFanSpeed sets the fan speed in percent
	SetFanSpeed(_ context.Context, speed uint8) error
	// SetStealthMode sets the stealth mode
	SetStealthMode(_ context.Context, enabled bool) error

	// WaitForIdentifyConfirm blocks until the user confirms the identify mode
	WaitForIdentifyConfirm(ctx context.Context) error
}

ComputeBladeAgent implements the core-logic of the agent. It is responsible for handling events and interfacing with the hardware.

func NewComputeBladeAgent

func NewComputeBladeAgent(opts ComputeBladeAgentConfig) (ComputeBladeAgent, error)

type ComputeBladeAgentConfig

type ComputeBladeAgentConfig struct {

	// IdleLedColor is the color of the edge LED when the blade is idle mode
	IdleLedColor hal.LedColor
	// IdentifyLedColor is the color of the edge LED when the blade is in identify mode
	IdentifyLedColor hal.LedColor
	// CriticalLedColor is the color of the top(!) LED when the blade is in critical mode.
	// In the circumstance when >1 blades are in critical mode, the identidy function can be used to find the right blade
	CriticalLedColor hal.LedColor

	// StealthModeEnabled indicates whether stealth mode is enabled
	StealthModeEnabled bool

	// DefaultFanSpeed is the default fan speed in percent. Usually 40% is sufficient
	DefaultFanSpeed uint

	// Critical temperature of the compute blade (used to trigger critical mode)
	CriticalTemperature uint
}

type ComputebladeState

type ComputebladeState interface {
	RegisterEvent(event Event)
	IdentifyActive() bool
	WaitForIdentifyConfirm(ctx context.Context) error
	CriticalActive() bool
	WaitForCriticalClear(ctx context.Context) error
}

func NewComputeBladeState

func NewComputeBladeState() ComputebladeState

type Event

type Event int

func (Event) String

func (e Event) String() string

Jump to

Keyboard shortcuts

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