Savory / Danet

The most mature backend framework for Deno. Create awesome HTTP and WebSocket server as well as KVQueue workers !
https://danet.land
Other
269 stars 18 forks source link

Suggestion: Task Scheduling #78

Closed marco-souza closed 7 months ago

marco-souza commented 7 months ago

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 {}


2. Then we can use the `@Cron` decorator to register listeners to timed events:

```ts
@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

marco-souza commented 7 months ago

I'll send a draft for this later this week šŸ‘šŸ¼