Socket
Socket
Sign inDemoInstall

adonis-jobs

Package Overview
Dependencies
39
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    adonis-jobs

This package is available in the npm registry.


Version published
Weekly downloads
5
increased by400%
Maintainers
1
Install size
9.74 MB
Created
Weekly downloads
 

Readme

Source

adonis-jobs

Download Version License

adonis-jobs is a queue system based on BullMQ for AdonisJS.

Note

You must have a Redis server running on your machine.


Getting Started

This package is available in the npm registry.

npm install adonis-jobs

Next, configure the package by running the following command.

node ace configure adonis-jobs

and... Voilà!

Usage

The Queue provider gives you access to the dispatch method. It will dispatch the linked job to the queue with the given payload.

import { Queue } from '@ioc:Setten/Queue';

Queue.dispatch('App/Jobs/RegisterStripeCustomer', {...});

Your Job can be stored anywhere in your application and is dispatched using its full path. It must have a handle method that will be executed by the queue worker.

// app/Jobs/RegisterStripeCustomer.ts

export type RegisterStripeCustomerPayload = {
  userId: string
}

export default class RegisterStripeCustomer {
  public async handle(payload: RegisterStripeCustomerPayload) {
    // ...
  }
}

Run the queue worker with the following ace command:

node ace queue:listen

Once done, you will see the message Queue processing started.

Typings

You can define the payload's type for a given job inside the contracts/queue.ts file.

import type { RegisterStripeCustomerPayload } from 'App/Jobs/RegisterStripeCustomer'

declare module '@ioc:Setten/Queue' {
  interface JobsList {
    'App/Jobs/RegisterStripeCustomer': RegisterStripeCustomerPayload;
  }
}

Keywords

FAQs

Last updated on 26 Jul 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc