winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

Schedule fails to compile when using `cron: "* * * * *"` #2849

Closed skyrpex closed 8 months ago

skyrpex commented 1 year ago

I tried this:

wing compile cron.w -t sim                     
// cron.w
bring cloud;
bring redis;

let cronSchedule = new cloud.Schedule(cloud.ScheduleProps{
  cron: "* * * * *"
}) as "Cron Schedule";

cronSchedule.onTick(inflight () => {
  log("Cron schedule ticked!");
});

This happened:

Error: ERROR: cannot use * in both the Day-of-month and Day-of-week fields. If you use it in one, you must use ? in the other

demo/target/index.wsim.294604.tmp/.wing/preflight.js:513
       );
       (rateSchedule.onTick(new $Closure8(this,"$Closure8")));
>>     const cronSchedule = this.node.root.newAbstract("@winglang/sdk.cloud.Schedule",this,"Cron Schedule",{
       "cron": "* * * * *",}
       );

I expected this:

It should compile and the scheduler should tick every minute.

Is there a workaround?

I don't know.

Component

Compiler, SDK

Wing Version

0.19.4

Wing Console Version

No response

Node.js Version

18.16.0

Platform(s)

MacOS

Anything else?

No response

Community Notes

staycoolcall911 commented 1 year ago

@skyrpex this is by design - @tsuf239 fixed added this in response to a Terraform error in #2744. You can see the error message (perhaps it should be improved?) and just change your cron expression to * * * * ?

skyrpex commented 1 year ago

Oh, my knowledge on cron syntax is quite lacking but when I have to work with it I use https://crontab.guru. The website says * * * * * is valid but * * * * ? isn't.

So I guess there are different syntaxes 🤔

staycoolcall911 commented 1 year ago

Thanks @skyrpex - I'll make sure to discuss it with @tsuf239

Chriscbr commented 1 year ago

Reopening since I also just ran into this issue. I believe it's a bug since "?" is not a standard part of the unix cron format (not mentioned on the link shared by @skyrpex, and on the wikipedia page here it's listed as a non-standard character).

One of the design tenets of our standard library is for APIs to be agnostic to the target cloud. If AWS has a unique format, the implementation for the AWS target can convert the cron string into a format that AWS supports. Nitric provides a nice example of how they handle this: https://nitric.io/docs/schedules#using-cron

github-actions[bot] commented 1 year ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

ekeren commented 1 year ago

keep

On Tue, Aug 8, 2023 at 9:05 AM github-actions[bot] @.***> wrote:

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/winglang/wing/issues/2849#issuecomment-1668960955, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANFVK6MUCUCF5CECHKJB5TXUHJJTANCNFSM6AAAAAAY65TPII . You are receiving this because you are subscribed to this thread.Message ID: @.***>

github-actions[bot] commented 1 year ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

monadabot commented 8 months ago

Congrats! :rocket: This was released in Wing 0.61.8.

staycoolcall911 commented 8 months ago

Reopening, since this was reverted in #5953

staycoolcall911 commented 8 months ago

Related discussion on Slack: https://winglang.slack.com/archives/C048QCN2XLJ/p1710573042627429

monadabot commented 8 months ago

Congrats! :rocket: This was released in Wing 0.61.14.