Savory/Danet

Suggestion: Task Scheduling

marco-souza opened this issue · 1 comments

Is your feature request related to a problem? Please describe.

As a Nest.JS developer, I'd like the possibility of running cron jobs using the framework decorators and module system.

References:

Describe the solution you'd like

I imagine something like this:

  1. First we register the module at the App root module:
@Module({
  imports: [
    ScheduleModule.forRoot()
  ],
})
export class AppModule {}
  1. Then we can use the @Cron decorator to register listeners to timed events:
@Injectable()
export class TasksService {
  private readonly logger = new Logger(TasksService.name);

  @Cron('45 * * * * *')
  handleCron() {
    this.logger.debug('Called when the current second is 45');
  }
}

The ScheduleModule can be totally made using Deno native features, like the Deno.Cron module

Other than that, I think the implementation should be fairly similar to the Events feature (#76)

Describe alternatives you've considered

I'll send a draft for this later this week 👍🏼