Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reg2005/adonis5-bullmq
Adonis 5 BullMQ provider
https://github.com/reg2005/adonis5-bullmq
Last synced: about 1 month ago
JSON representation
Adonis 5 BullMQ provider
- Host: GitHub
- URL: https://github.com/reg2005/adonis5-bullmq
- Owner: reg2005
- Created: 2021-02-07T21:39:16.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-18T09:22:33.000Z (over 1 year ago)
- Last Synced: 2024-11-08T06:43:40.740Z (about 1 month ago)
- Language: TypeScript
- Size: 696 KB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
- awesome-adonisjs - Adonis BullMQ - Simple BullMQ provider for you own queue commands (Packages)
README
## Table of contents
- [adonis5-bullmq](#adonis5-bullmq)
- [Installation](#installation)
- [Usage](#usage)
- [Create your props interface and enums](#create-your-props-interface-and-enums)
- [Create queue listener](#create-queue-listener)
- [Emit job](#emit-job)# adonis5-bullmq
> Tagline[![npm-image]][npm-url] [![license-image]][license-url] [![typescript-image]][typescript-url]
BullMQ provider for Adonis5
## Installation
```bash
npm i adonis5-bullmq```
```bash
node ace invoke adonis5-bullmq
```## Usage
### Create your props interface and enums
```ts
// file: Contracts/QueueInterfaces.ts
export interface TestProps {
name: string
}
export enum QueueNamesEnum {
'TestJob' = 'TestJob'
}
```### Create queue listener
```ts
// file commands/QueueListener.ts
import BullMQ from '@ioc:Adonis/Addons/BullMQ'
import {TestProps, QueueNamesEnum} from 'Contracts/QueueInterfaces'export default class QueueListener extends BaseCommand {
/**
* Command Name is used to run the command
*/
public static commandName = 'queue:listener'public static settings = {
loadApp: true,
}run(){
BullMQ.worker(QueueNamesEnum.TestJob, async (job) => {
console.log(job.data)
// handle your job
return job
})
}
}
```### Emit job
```ts
// anyAppFile.ts
import BullMQ from '@ioc:Adonis/Addons/BullMQ'
import {TestProps, QueueNamesEnum} from 'Contracts/QueueInterfaces'const queue = BullMQ.queue(QueueNamesEnum.TestJob)
export default class IndexController {
async send(){
await queue.add('mytestJob', { name: 'anyName' })
}
}
```[npm-image]: https://img.shields.io/npm/v/adonis5-bullmq.svg?style=for-the-badge&logo=npm
[npm-url]: https://npmjs.org/package/adonis5-bullmq "npm"[license-image]: https://img.shields.io/npm/l/adonis5-bullmq?color=blueviolet&style=for-the-badge
[license-url]: LICENSE.md "license"[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[typescript-url]: "typescript"