VeryGoodOpenSource / dart_frog

A fast, minimalistic backend framework for Dart 🎯
https://dartfrog.vgv.dev
MIT License
1.87k stars 150 forks source link

feat: Scheduled Tasks / Cron Jobs #1244

Closed markbreuss closed 7 months ago

markbreuss commented 10 months ago

Description

I would like to be able to have scheduled tasks that run on a specified Interval (cron job) I am not entirely sure if this is already possible by third party dependencies or if this should even be part of the package. For example by using: https://pub.dev/packages/cron

In any case I would greatly appreceate a hint or even a dart_frog feature which allows this funtionality.

Requirements

Additional Context

My specific use cases is an email that should be send every night 23pm from a dart_frog server.

UPDATE: I ended up using the package above and it works great - in hindsight this has nothing to do with dart_frog itself. I'll close this isssue as it works with existing packages.

plato79 commented 7 months ago

I'm not sure but are you sure it should be included in dart_frog? This is a service which returns a response when a request is made. You want it to handle both request and response. I think you should separate your project and create an app which requests the server to send a mail at appointed date/time.

The request should be something like this:

{
  "action":"send_mail",
  "start_date":"05/05/2024",
  "start_time":"23:00:00",
  "repeat":"1d"
}

Then you should also define a response which executes that mail every day at the "repeat" interval...

Something like this maybe?