check

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCheckCron

func NewCheckCron(
	creator CheckCreator,
	runner ChecksRunner,
	interval time.Duration,
) run.Func

Types

type Check

type Check interface {
	Apply(ctx context.Context) error
	Satisfied(ctx context.Context) (bool, error)
	Name() string
}

Check is something is in the right state

func Func

func Func(
	name string,
	satisfied func(ctx context.Context) (bool, error),
	apply func(ctx context.Context) error,
) Check

func NewAlternateSwitch

func NewAlternateSwitch(
	now time.Time,
	mainDuration time.Duration,
	secondDuration time.Duration,
	main,
	fallback Check,
) Check

func NewBetweenMinuteSwitch

func NewBetweenMinuteSwitch(
	now time.Time,
	fromMinute, untilMinute int,
	main, fallback Check,
) Check

func NewBetweenTimeSwitch

func NewBetweenTimeSwitch(now time.Time, from, until pkg.TimeOfDay, main, fallback Check) Check

NewBetweenTimeSwitch turns on main between the given hours and fallback if not

func NewLightIsOff

func NewLightIsOff(
	bridge *huego.Bridge,
	lightName pkg.LightName,
) Check

func NewLightIsOn

func NewLightIsOn(
	bridge *huego.Bridge,
	lightName pkg.LightName,
) Check

func NewSwitch

func NewSwitch(fn func() bool, main, fallback Check) Check

NewSwitch returns main if fn returns true otherwise fallback

type CheckCreator

type CheckCreator interface {
	CreateChecks(ctx context.Context) (Checks, error)
}

func NewCheckCreator

func NewCheckCreator(
	provider pkg.BridgesProvider,
	summerMode bool,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) CheckCreator

type Checks

type Checks []Check

type ChecksRunner

type ChecksRunner interface {
	RunChecks(ctx context.Context, checks Checks) error
}

func NewChecksRunner

func NewChecksRunner() ChecksRunner

Jump to

Keyboard shortcuts

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