Agenda - v6.0.0
    Preparing search index...

    Function Every

    • Method decorator that defines a recurring job.

      Jobs decorated with

      Parameters

      • interval: string | number

        The interval at which the job should run. Can be a cron expression, human-readable string, or milliseconds.

      • options: EveryOptions = {}

        Configuration options for the job

      Returns (
          target: any,
          propertyKey: string,
          descriptor: PropertyDescriptor,
      ) => PropertyDescriptor

      Method decorator

      are automatically scheduled when registered with the Agenda instance. They will run at the specified interval.

      import { JobsController, Every, Job } from 'agenda';

      @JobsController({ namespace: 'maintenance' })
      class MaintenanceJobs {
      // Run every 5 minutes
      @Every('5 minutes')
      async healthCheck(job: Job) {
      await this.checkSystemHealth();
      }

      // Run daily at midnight using cron
      @Every('0 0 * * *', {
      name: 'dailyCleanup',
      timezone: 'America/New_York'
      })
      async cleanupOldData(job: Job) {
      await this.deleteOldRecords();
      }

      // Run every hour with high priority
      @Every('1 hour', { priority: 'high', concurrency: 1 })
      async generateReport(job: Job) {
      await this.createHourlyReport();
      }
      }