check

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 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,
	samplerFactory log.SamplerFactory,
) run.Func

NewCheckCron creates a run.Func that periodically creates and runs the checks on the given interval, logging run failures at most once per sampling window via the injected sampler factory.

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) (CheckList, error)
}

func NewCheckCreator

func NewCheckCreator(
	provider pkg.BridgesProvider,
	summerMode bool,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
	location *time.Location,
	sunriseSunsetProvider pkg.SunriseSunsetProvider,
) CheckCreator

type CheckList added in v0.6.0

type CheckList []Check

type ChecksRunner

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

func NewChecksRunner

func NewChecksRunner(
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
	dryRun bool,
) ChecksRunner

Jump to

Keyboard shortcuts

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