domain

package
v0.0.0-...-34c5bf1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 3 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 {
	ScheduleID int
	Property   string
	Value      string
	Type       string
}

Action is a single change to make to a device

type Actor

type Actor struct {
	Identifier     string `json:"identifier"`
	ControllerName string `json:"controller_name"`
}

Actor represents a device to perform an action on

type Rule

type Rule struct {
	Second  *int // 0-59
	Minute  *int // 0-59
	Hour    *int // 0-23
	Weekday *int // 0-6 (Sunday = 0)
	Day     *int // 1-31
	Month   *int // 1-12
}

Rule represents a periodic time

func (*Rule) CalculateNextRunAfterTime

func (r *Rule) CalculateNextRunAfterTime(t time.Time) (time.Time, error)

CalculateNextRunAfterTime returns the first time that the rule describes that is later than the given time t

type Schedule

type Schedule struct {
	gorm.Model

	// ActorID is the ID of the controller to act upon
	ActorID string

	// Actions is the list of actions to perform
	Actions []Action

	// StartTime is the earliest time that the schedule can run.
	// N.b. it might not run at this time if the rules do not permit.
	StartTime time.Time

	// NextRun is a cache of the next run time
	NextRun time.Time

	// Count is the number of times the schedule should run.
	// A value of -1 will run the schedule ad infinitum.
	Count int

	// Until is the end date of the schedule
	Until time.Time
}

Schedule wraps a set of rules and a set of actions

Jump to

Keyboard shortcuts

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