scheduler

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Host  string
	State bool
}

Action represents a state change for a host

type RegisteredHost

type RegisteredHost struct {
	Name        string
	State       bool
	Failures    int
	LastUpdated time.Time
}

RegisteredHost holds the state of a registered host

func (RegisteredHost) IsAlive

func (rc RegisteredHost) IsAlive() bool

IsAlive reports if the host is up or down. If the host has been unavailable 5 times in a row, it's considered "down". One successful request marks it as "up" again

func (*RegisteredHost) UpdateStatus

func (rc *RegisteredHost) UpdateStatus(alive bool)

UpdateStatus updates the status of the host

type Scheduler

type Scheduler struct {
	schedule.Schedule
	// contains filtered or unexported fields
}

Scheduler records the list of hosts and calculates the next host(s) whose LED should be switched on

func New

New creates a Scheduler based on the provided pattern name

func (*Scheduler) GetHosts

func (s *Scheduler) GetHosts() (hosts []RegisteredHost)

GetHosts returns all registered hosts (regardless of their state)

func (*Scheduler) Next

func (s *Scheduler) Next() (actions []Action)

Next determines the required actions for the next state

func (*Scheduler) Register

func (s *Scheduler) Register(name string)

Register registers the provided host

func (*Scheduler) UpdateStatus

func (s *Scheduler) UpdateStatus(name string, alive bool)

UpdateStatus updates the status (up/down) of the provided host

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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