Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Task Scheduling #78

Closed
marco-souza opened this issue Feb 19, 2024 · 1 comment · Fixed by #79
Closed

Suggestion: Task Scheduling #78

marco-souza opened this issue Feb 19, 2024 · 1 comment · Fixed by #79

Comments

@marco-souza
Copy link
Contributor

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

@marco-souza
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant