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.04k stars 196 forks source link

Support intervals with Wing #7090

Open boyney123 opened 2 months ago

boyney123 commented 2 months ago

Use Case

I'm trying to understand if I can use intervals with Wing, other programming languages have them

For example: A as a developer writing containerised code, maybe I want to setup an interval to hit an endpoint every X seconds

Proposed Solution

Maybe util.setInterval(func, duration) would work? Or something similar?

Only inflight support I imagine?

Implementation Notes

No response

Component

No response

Community Notes

Chriscbr commented 2 months ago

A way to create timers or ticker would be great to have for inflight code. We can start by porting JavaScript's built-in APIs straight over for initial support:

inflight () => {
  let id: num = util.setInterval(func, 5s); // run "func" every 5s
  // ...
  util.clearInterval(id); // stop the timer
};

Adding this as a good first issue.

Only inflight support I imagine?

Yeah, I think so.

Pushkarm029 commented 1 week ago

I can help with this issue.