Skip to content
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

(synthetics): add static cron method to schedule class #16402

Closed
1 of 2 tasks
kaizencc opened this issue Sep 7, 2021 · 1 comment · Fixed by #17250
Closed
1 of 2 tasks

(synthetics): add static cron method to schedule class #16402

kaizencc opened this issue Sep 7, 2021 · 1 comment · Fixed by #17250
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@kaizencc
Copy link
Contributor

kaizencc commented Sep 7, 2021

cron expressions are now allowed on synthetic canaries. Similar to app-autoscaling and autoscaling and other modules, the synthetic Schedule class should support a static cron method that takes in cronOptions.

I think we can (and should) talk about moving Schedule to core. I tried that in #9250 and perhaps we can revive that conversation.

Use Case

Syntactic sugar and to offer the same user experience across modules.

Proposed Solution

Here's how its done in application autoscaling:

public static cron(options: CronOptions): Schedule {
if (options.weekDay !== undefined && options.day !== undefined) {
throw new Error('Cannot supply both \'day\' and \'weekDay\', use at most one');
}
const minute = fallback(options.minute, '*');
const hour = fallback(options.hour, '*');
const month = fallback(options.month, '*');
const year = fallback(options.year, '*');
// Weekday defaults to '?' if not supplied. If it is supplied, day must become '?'
const day = fallback(options.day, options.weekDay !== undefined ? '?' : '*');
const weekDay = fallback(options.weekDay, '?');
return new LiteralSchedule(`cron(${minute} ${hour} ${day} ${month} ${weekDay} ${year})`);
}

Other

The current work around is to use Schedule.expression('cron(* * * * *)').
Related: #16392.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@kaizencc kaizencc added p2 feature-request A feature should be added or improved. @aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics labels Sep 7, 2021
@kaizencc kaizencc added the effort/small Small work item – less than a day of effort label Sep 7, 2021
@kaizencc kaizencc added the good first issue Related to contributions. See CONTRIBUTING.md label Sep 7, 2021
@mergify mergify bot closed this as completed in #17250 Nov 2, 2021
mergify bot pushed a commit that referenced this issue Nov 2, 2021
closes #16402

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Nov 2, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
closes aws#16402

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-synthetics Related to Amazon CloudWatch Synthetics effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants