Skip to content

Commit

Permalink
Updated schedule options (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb authored Oct 8, 2024
1 parent 6f5395d commit cda2f4a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 13 deletions.
23 changes: 23 additions & 0 deletions v1/scheduler/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,26 @@ const (
// TimeZoneCIT Charge Initialisation Time (Midnight = Charge Time)
TimeZoneCIT TimeZone = "CIT"
)

type DayType string

const (
// DayTypeNone indicates no specific day type
DayTypeNone DayType = ""
// DayTypeWeekday indicates a weekday Monday to Friday
DayTypeWeekday DayType = "weekday"
// DayTypeWeekend indicates a weekend day Saturday or Sunday
DayTypeWeekend DayType = "weekend"
)

type DayShift string

const (
DayShiftNone DayShift = ""
// DayShiftForward move the date forward to match the day
DayShiftForward DayShift = "forward"
// DayShiftBackward move the date backward to match the day
DayShiftBackward DayShift = "backward"
// DayShiftClosest move the date to the closest day
DayShiftClosest DayShift = "closest"
)
39 changes: 26 additions & 13 deletions v1/scheduler/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,40 @@ type Schedule struct {
// AttemptConfig is the configuration to use when processing this schedule
AttemptConfig AttemptConfig `json:"attemptConfig" yaml:"attemptConfig" validate:"required,dive"`

// TimeDelay is the amount of time to wait before processing after TimeDelayOrigin
TimeDelay time.Duration `json:"timeDelay" yaml:"timeDelay" validate:"gte=0"`
// TimeDelay [deprecated - prefer delay days] is the amount of time to wait before processing after TimeDelayOrigin
TimeDelay time.Duration `json:"timeDelay,omitempty" yaml:"timeDelay" validate:"gte=0"`

// DAY CONFIG

// DelayDays is the number of days to delay the schedule by
DelayDays int `json:"delayDays,omitempty" yaml:"delayDays" validate:"gte=0"`

// DayOfMonth is the day of the month to process the schedule
DayOfMonth int `json:"dayOfMonth,omitempty" yaml:"dayOfMonth" validate:"min=0,max=28"`

// DayOfWeek is the day of the week to process the schedule (1 = Monday) - Sunday moved to 7 to leave 0 as an ignored value
DayOfWeek int `json:"dayOfWeek,omitempty" yaml:"dayOfWeek" validate:"min=0,max=7"`

// DayType indicates the type of day to process the schedule
DayType DayType `json:"dayType,omitempty" yaml:"dayType" validate:"oneof='' weekday weekend"`

// DayShift indicates the direction to take when syncing to Days
DayShift DayShift `json:"daySync,omitempty" yaml:"daySync" validate:"oneof='' forward backward"`

// TIME CONFIG

// TimeDelayOrigin specifies when the time origin is based from
TimeDelayOrigin AttemptOriginType `json:"timeDelayOrigin" yaml:"timeDelayOrigin" validate:"oneof=initialisation last-failure"`
TimeDelayOrigin AttemptOriginType `json:"timeDelayOrigin,omitempty" yaml:"timeDelayOrigin" validate:"oneof=initialisation last-failure"`

// TimeDelaySync indicates the direction in time that the schedule should move when syncing to TimeSyncHour
TimeDelaySync TimeDelaySync `json:"timeDelaySync" yaml:"timeDelaySync" validate:"oneof=None Earliest Latest Closest"`
TimeDelaySync TimeDelaySync `json:"timeDelaySync,omitempty" yaml:"timeDelaySync" validate:"oneof=None Earliest Latest Closest"`

// TimeSyncHour is an hour designation (0-23) i.e 2 == 2AM. Ignored if TimeDelaySync is set to None
TimeSyncHour int `json:"timeSyncHour" yaml:"timeSyncHour" validate:"min=0,max=23"`
TimeSyncHour int `json:"timeSyncHour,omitempty" yaml:"timeSyncHour" validate:"min=0,max=23"`

// TimeWindowHours is the number of hours grace for a transaction to be processed within. Allowing for a transaction to be processed within X hours of the requested delay & sync hour e.g. 10am > 11am with a TimeWindowHours of 1
TimeWindowHours int `json:"timeWindowHours" yaml:"timeWindowHours" validate:"gte=0"`
TimeWindowHours int `json:"timeWindowHours,omitempty" yaml:"timeWindowHours" validate:"gte=0"`

// TimeSyncZone indicates the timezone that the TimeSyncHour is relative to. Ignored if TimeDelaySync is set to None
TimeSyncZone TimeZone `json:"timeSyncZone" yaml:"timeSyncZone" validate:"oneof=ULT UTC CIT"`

// DayOfMonth is the day of the month to process the schedule
DayOfMonth int `json:"dayOfMonth" yaml:"dayOfMonth" validate:"min=0,max=28"`

// DayOfWeek is the day of the week to process the schedule (1 = Monday) - Sunday moved to 7 to leave 0 as an ignored value
DayOfWeek int `json:"dayOfWeek" yaml:"dayOfWeek" validate:"min=0,max=7"`
TimeSyncZone TimeZone `json:"timeSyncZone,omitempty" yaml:"timeSyncZone" validate:"oneof=ULT UTC CIT"`
}

0 comments on commit cda2f4a

Please sign in to comment.