# adonis-queue

> Bull provider for the Adonis framework

Latest version **1.0.1** (published 2016-09-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install adonis-queue
pnpm add adonis-queue
yarn add adonis-queue
bun add adonis-queue
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-09-10 |
| First published | 2016-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nicholas Rempel |
| Maintainers | nbrempel |
| Keywords | adonis, bull, queue |

## Links

- npm: https://www.npmjs.com/package/adonis-queue
- Repository: https://github.com/nrempel/adonis-bull
- Homepage: https://github.com/nrempel/adonis-bull#readme
- Issues: https://github.com/nrempel/adonis-bull/issues
- npm.io page: https://npm.io/package/adonis-queue

## Dependencies (2)

- [co](https://npm.io/package/co.md) ^4.6.0
- [bull](https://npm.io/package/bull.md) ^1.0.0

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-09-10
- 1.0.0 — 2016-09-10

## README

# Adonis Queue Provider

A job queuing provider that leverages [Bull](https://github.com/OptimalBits/bull) for the AdonisJS framework.

This library provides an easy way to get started with an asynchronous job queue for AdonisJS.

## Install

```
npm install --save adonis-bull
```

## Configure

Register it in `bootstrap/app.js`:

```javascript
const providers = [
  ...
  'adonis-queue/providers/QueueProvider'
]
```

Also consider adding an alias to the provider.

```javascript
const aliases = {
  ...
  Queue: 'Adonis/Addons/Queue'
}
```

Register the commands:

```javascript
const aceProviders = [
  ...
  'adonis-queue/providers/CommandsProvider'
];

...

const commands = [
  ...
  'Adonis/Commands/Queue:Listen'
];
```

Add a configuration file in `config/queue.js`. For example:

```javascript
'use strict';

const Env = use('Env');

module.exports = {
  redis: {
    connectionString: 'redis://localhost:6379'
  }
};

```

## Usage

### Starting the listener

Starting an instance of the queue listener is easy with the included ace command. Simply run `./ace queue:listen`.

The provider looks for jobs in the `app/Jobs` directory of your AdonisJS project and will automatically register a handler for any jobs that it finds.

### Creating your first job

Jobs are easy to create. They live in `app/Jobs` and they are a simple class. They expose the following properties:

| Name        | Required | Type      | Static | Description                                           |
|-------------|----------|-----------|--------|-----------------------------------------------|
| concurrency | false    | number    | true   | The number of concurrent jobs the handler will accept |
| key         | true     | string    | true   | A unique key for this job                             |
| handle      | true     | function  | false  | A function that is called for this job.               |

[Here's an example.](examples/app/Jobs/Example.js)

### Dispatching jobs

Now that your job listener is running and ready to do some asynchronous work, you can start dispatching jobs. 

```javascript
const queue = use('Queue');
const Job = require('./app/Jobs/Example');
const data = { test: 'data' };
queue.dispatch(Job.key, data);
```

## Thanks

Special thanks to the creator(s) of [AdonisJS](http://adonisjs.com/) for creating such a great framework.

---
_Source: https://npm.io/package/adonis-queue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
