diff --git a/v1/scheduler/enums.go b/v1/scheduler/enums.go index 0c78702..7dc11a2 100644 --- a/v1/scheduler/enums.go +++ b/v1/scheduler/enums.go @@ -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" +) diff --git a/v1/scheduler/schedule.go b/v1/scheduler/schedule.go index 3fe29de..86fac39 100644 --- a/v1/scheduler/schedule.go +++ b/v1/scheduler/schedule.go @@ -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"` }