©️
Cross api
En-US
En-US
  • Introduction
  • Compatibility
  • Extensions
  • Usage
    • Tools
      • Config
      • ListProvider
      • Language
      • Help
    • Structure
      • MakeApi
      • MakeModule
      • MakeProvider
      • Revert
  • Structure
    • Root
    • Src
    • @Types
    • Assets
    • Config
    • Dtos
    • Jobs
    • Keys
    • Middlewares
    • Modules
    • Routes
    • Shared
    • Utils
  • Services
    • Transactions
    • Exists
    • FindBy
    • FindIn
    • FindLike
    • FindAll
    • Create
    • CreateMany
    • Update
    • UpdateMany
    • Delete
    • DeleteMany
    • SoftDelete
    • SoftDeleteMany
  • Mappers
    • CloneAttribute
    • UpdateAttribute
    • PatchAttribute
    • UpdateString
    • PatchString
    • InsertAttribute
  • Providers
    • Cache
    • Crypto
    • Hash
    • Lead
    • MailTemplate
    • Mail
    • Queue
    • Notification
    • Storage
Powered by GitBook
On this page
  • Available:
  • Jobs:
  • Methods:

Was this helpful?

  1. Providers

Queue

A queue service to run tasks in the background or schedule them to run at a certain time.

Available:

  • Bee

  • Bull

  • Kue

  • Fake

Jobs:

The structure is simple, it should be a class with a static key method to retrieve its key and a public handle method to perform the task. All other OOP features for distributing logic are allowed.

export class Example {
  public static get key(): Capitalize<string> {
    return 'Example';
  }

  public async handle({ data }: { data: { message: string } }): Promise<void> {
    return console.log('I have a message for you: %s', data.message);
  }
}

Methods:

Execute: Runs a task in the background, if it fails it repeats a certain number of times.

await this.queueProvider.execute<{ message: string }>(
  Example.key,
  {
    message: 'This is the message',
  },
  3,
);

Schedule: Schedules a task in the background, if it fails it repeats a certain number of times.

await this.queueProvider.schedule<{ message: string }>(
  Example.key,
  {
    message: 'This is the message',
  },
  '30min',
  3,
);

PreviousMailNextNotification

Last updated 5 months ago

Was this helpful?