switcher

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Setter

type Setter interface {
	SetLED(state bool) error
	GetLED() bool
}

type Switcher

type Switcher struct {
	Registerer *registerer.Registerer
	// contains filtered or unexported fields
}

Switcher implements the ledswitcher logic. It contains:

  1. a Leader that will determine the next LED to switch on, based on the registered endpoints
  2. a Registerer that will continuously attempt to register the endpoint with the Leader
  3. a Server that will listen for incoming requests, be it registration requests from other endpoints (if leading), or requests from the Leader to switch the LED on/off.

Each Switcher contains all three components. the Configuration's Leader field determines if the switcher is the Leader.

func New

func New(cfg configuration.Configuration, logger *slog.Logger) (*Switcher, error)

New creates a new Switcher

func (*Switcher) Collect

func (s *Switcher) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface

func (*Switcher) Describe

func (s *Switcher) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface

func (*Switcher) Run

func (s *Switcher) Run(ctx context.Context) error

Run starts a Switcher and waits for the context to be canceled

func (*Switcher) SetLeader

func (s *Switcher) SetLeader(leader string)

SetLeader reconfigures the Switcher when the hostname changes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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