Documentation
¶
Index ¶
- type CompositeDailySchedule
- type CronTrigger
- type DailyScheduleBuilder
- func (b *DailyScheduleBuilder) Build() (Spec, error)
- func (b *DailyScheduleBuilder) OnCron(expression string) *DailyScheduleBuilder
- func (b *DailyScheduleBuilder) OnFixedTime(hour, minute int) *DailyScheduleBuilder
- func (b *DailyScheduleBuilder) OnSunrise(offset ...types.DurationString) *DailyScheduleBuilder
- func (b *DailyScheduleBuilder) OnSunset(offset ...types.DurationString) *DailyScheduleBuilder
- type FixedTimeTrigger
- type IntervalTrigger
- type Location
- type Spec
- type SunTrigger
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompositeDailySchedule ¶
type CompositeDailySchedule struct {
// contains filtered or unexported fields
}
CompositeDailySchedule combines multiple triggers into a single daily schedule.
func (*CompositeDailySchedule) Hash ¶
func (c *CompositeDailySchedule) Hash() uint64
Hash returns a stable hash value for the CompositeDailySchedule
func (*CompositeDailySchedule) NextTime ¶
func (c *CompositeDailySchedule) NextTime(now time.Time) *time.Time
NextTime returns the next time the first viable trigger will run.
func (*CompositeDailySchedule) String ¶
func (c *CompositeDailySchedule) String() string
type CronTrigger ¶
type CronTrigger struct {
// contains filtered or unexported fields
}
CronTrigger represents a trigger based on a cron expression.
func NewCronTrigger ¶
func NewCronTrigger(expression string) (*CronTrigger, error)
NewCronTrigger creates a new CronTrigger from a cron expression.
func (*CronTrigger) Hash ¶
func (t *CronTrigger) Hash() uint64
Hash returns a stable hash value for the CronTrigger.
func (*CronTrigger) NextTime ¶
func (t *CronTrigger) NextTime(now time.Time) *time.Time
NextTime calculates the next occurrence of this cron trigger after the given time.
func (*CronTrigger) String ¶
func (t *CronTrigger) String() string
type DailyScheduleBuilder ¶
type DailyScheduleBuilder struct {
// contains filtered or unexported fields
}
func NewSchedule ¶
func NewSchedule() *DailyScheduleBuilder
func (*DailyScheduleBuilder) Build ¶
func (b *DailyScheduleBuilder) Build() (Spec, error)
Build returns a Spec that resolves to a Trigger once the observer location is known. It will return an error if any errors occurred during configuration.
func (*DailyScheduleBuilder) OnCron ¶
func (b *DailyScheduleBuilder) OnCron(expression string) *DailyScheduleBuilder
OnCron adds a trigger driven by a five field cron expression.
func (*DailyScheduleBuilder) OnFixedTime ¶
func (b *DailyScheduleBuilder) OnFixedTime(hour, minute int) *DailyScheduleBuilder
OnFixedTime adds a trigger for a fixed time each day. The time is in the local timezone. This will error if the integer values are not in the range 0-23 for the hour and 0-59 for the minute.
func (*DailyScheduleBuilder) OnSunrise ¶
func (b *DailyScheduleBuilder) OnSunrise(offset ...types.DurationString) *DailyScheduleBuilder
OnSunrise adds a trigger for sunrise with an optional offset. Only the first offset is considered. You can call this multiple times to add multiple triggers for sunrise with different offsets.
func (*DailyScheduleBuilder) OnSunset ¶
func (b *DailyScheduleBuilder) OnSunset(offset ...types.DurationString) *DailyScheduleBuilder
OnSunset adds a trigger for sunset with an optional offset. Only the first offset is considered.
type FixedTimeTrigger ¶
FixedTimeTrigger represents a trigger at a specific hour and minute each day
func (*FixedTimeTrigger) Hash ¶
func (t *FixedTimeTrigger) Hash() uint64
Hash returns a stable hash value for the FixedTimeTrigger
func (*FixedTimeTrigger) String ¶
func (t *FixedTimeTrigger) String() string
type IntervalTrigger ¶
type IntervalTrigger struct {
// contains filtered or unexported fields
}
IntervalTrigger represents a trigger that fires at a sequence of intervals.
func NewIntervalTrigger ¶
func NewIntervalTrigger(interval time.Duration, additional ...time.Duration) (*IntervalTrigger, error)
NewIntervalTrigger creates a new IntervalTrigger from one or more durations. An error is returned if no intervals are provided or if any interval is not positive. The epoch is the reference point for all interval calculations. The duration between each time alternates between each interval (or, if there is only one interval, it is the interval). For example, if the intervals are [1h, 2h, 3h], the first time will be at epoch + 1h, the second time will be at epoch + 1h + 2h, the third time will be at epoch + 1h + 2h + 3h, and so on.
func (*IntervalTrigger) Hash ¶
func (t *IntervalTrigger) Hash() uint64
Hash returns a stable hash value for the IntervalTrigger.
func (*IntervalTrigger) NextTime ¶
func (t *IntervalTrigger) NextTime(now time.Time) *time.Time
NextTime calculates the next occurrence of this interval trigger after the given time.
func (*IntervalTrigger) String ¶
func (t *IntervalTrigger) String() string
func (*IntervalTrigger) WithEpoch ¶
func (t *IntervalTrigger) WithEpoch(epoch time.Time) *IntervalTrigger
WithEpoch returns a copy of the trigger anchored to epoch, the reference point for all interval calculations. It copies rather than mutates so that two automations built from one builder chain cannot end up sharing an epoch.
type Spec ¶
Spec describes a trigger that cannot be built until the observer location is known. Schedules are declared as package level values before an App exists, so sun triggers have nowhere to read coordinates from until registration.
type SunTrigger ¶
type SunTrigger struct {
// contains filtered or unexported fields
}
SunTrigger represents a trigger based on sunrise or sunset with optional offset
func (*SunTrigger) Hash ¶
func (t *SunTrigger) Hash() uint64
Hash returns a stable hash value for the SunTrigger
func (*SunTrigger) NextTime ¶
func (t *SunTrigger) NextTime(now time.Time) *time.Time
NextTime returns the next time the sun will rise or set, with the offset applied. It scans forward day by day: today's event has usually passed by the time the scheduler asks, and the offset can push it either side of now.
func (*SunTrigger) String ¶
func (t *SunTrigger) String() string