-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(scheduler): flexible time windows #28098
Changes from 15 commits
ff675c0
85b60d4
5f3496b
b71fd8e
70362d5
21c4331
2a2b00d
24cebc1
e2ce811
8fc8d33
443fa09
9af2ec8
a8c279a
ba4630b
540561c
8169a6d
f509ef6
461f5ba
e990c2a
fb820e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -59,6 +59,47 @@ export interface ScheduleTargetProps { | |||||
readonly retryAttempts?: number; | ||||||
} | ||||||
|
||||||
/** | ||||||
* A time window during which EventBridge Scheduler invokes the schedule. | ||||||
*/ | ||||||
export class FlexibleTimeWindowMode { | ||||||
/** | ||||||
* FlexibleTimeWindow is disabled. | ||||||
*/ | ||||||
public static off(): FlexibleTimeWindowMode { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to camelCase because it resulted in an error during cdk-build.
|
||||||
return new FlexibleTimeWindowMode('OFF'); | ||||||
} | ||||||
|
||||||
/** | ||||||
* FlexibleTimeWindow is enabled. | ||||||
*/ | ||||||
public static flexible(maximumWindowInMinutes: Duration): FlexibleTimeWindowMode { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It doesn't need to be in minutes anymore cuz we're supplying a Duration |
||||||
if (maximumWindowInMinutes.toMinutes() < 1 || maximumWindowInMinutes.toMinutes() > 1440) { | ||||||
throw new Error(`maximumWindowInMinutes must be between 1 and 1440, got ${maximumWindowInMinutes.toMinutes()}`); | ||||||
} | ||||||
return new FlexibleTimeWindowMode('FLEXIBLE', maximumWindowInMinutes); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Determines whether the schedule is invoked within a flexible time window. | ||||||
*/ | ||||||
public readonly mode: string; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** | ||||||
* The maximum time window during which the schedule can be invoked. | ||||||
* | ||||||
* Must be between 1 to 1440 minutes. | ||||||
* | ||||||
* @default - Required if mode is FLEXIBLE. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't the correct use of the |
||||||
*/ | ||||||
public readonly maximumWindowInMinutes?: Duration; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
private constructor(mode: string, maximumWindowInMinutes?: Duration) { | ||||||
this.mode = mode; | ||||||
this.maximumWindowInMinutes = maximumWindowInMinutes; | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Construction properties for `Schedule`. | ||||||
*/ | ||||||
|
@@ -104,6 +145,7 @@ export interface ScheduleProps { | |||||
|
||||||
/** | ||||||
* Indicates whether the schedule is enabled. | ||||||
* | ||||||
* @default true | ||||||
*/ | ||||||
readonly enabled?: boolean; | ||||||
|
@@ -114,6 +156,15 @@ export interface ScheduleProps { | |||||
* @default - All events in Scheduler are encrypted with a key that AWS owns and manages. | ||||||
*/ | ||||||
readonly key?: kms.IKey; | ||||||
|
||||||
/** | ||||||
* A time window during which EventBridge Scheduler invokes the schedule. | ||||||
* | ||||||
* @see https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-schedule-flexible-time-windows.html | ||||||
* | ||||||
* @default FlexibleTimeWindowMode.off() | ||||||
*/ | ||||||
readonly flexibleTimeWindow?: FlexibleTimeWindowMode; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -254,9 +305,14 @@ export class Schedule extends Resource implements ISchedule { | |||||
|
||||||
this.retryPolicy = targetConfig.retryPolicy; | ||||||
|
||||||
const flexibleTimeWindow = props.flexibleTimeWindow ?? FlexibleTimeWindowMode.off(); | ||||||
|
||||||
const resource = new CfnSchedule(this, 'Resource', { | ||||||
name: this.physicalName, | ||||||
flexibleTimeWindow: { mode: 'OFF' }, | ||||||
flexibleTimeWindow: { | ||||||
mode: flexibleTimeWindow.mode, | ||||||
maximumWindowInMinutes: flexibleTimeWindow.maximumWindowInMinutes?.toMinutes(), | ||||||
}, | ||||||
scheduleExpression: props.schedule.expressionString, | ||||||
scheduleExpressionTimezone: props.schedule.timeZone?.timezoneName, | ||||||
groupName: this.group?.groupName, | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be nicer to write
TimeWindow.flexible()