Stone.js API
    Preparing search index...
    • Class decorator: mark a class as a job handler.

      The class is registered as a container service and contributed to stone.queue.handlers; the QueueServiceProvider resolves it (with dependency injection). With a name, jobs of that name are routed to the class's handle(payload, job) method. Without a name, the class carries one or more @OnJob('...') methods, one job per method.

      Type Parameters

      • T extends ClassType = ClassType

      Parameters

      • Optionalname: string

        The job name this class handles (omit when using @OnJob methods).

      • options: JobHandlerOptions = {}

        The action method for the whole-class form (defaults to handle).

      Returns ClassDecorator

      A class decorator.

      @JobHandler('send-email')
      export class SendEmail {
      constructor (private readonly mailer) {}
      async handle (payload: { to: string }) { await this.mailer.send(payload.to) }
      }

      @JobHandler()
      export class Jobs {
      @OnJob('resize') resize (payload) { ... }
      @OnJob('purge') purge (payload) { ... }
      }