{"_id":"@ashokgelal/adonis-bull","_rev":"3-192108ee4c9266e7b8ef3b2e881d671c","name":"@ashokgelal/adonis-bull","dist-tags":{"alpha":"0.2.4","latest":"0.2.2"},"versions":{"0.2.2":{"name":"@ashokgelal/adonis-bull","version":"0.2.2","main":"build/providers/BullProvider.js","license":"MIT","scripts":{"test:local":"node japaFile.js","test":"nyc npm run test:local","coverage":"nyc report --reporter=text-lcov | coveralls","copyfiles":"copyfiles \"templates/**/*.txt\" build","compile":"tsc","build":"npm run compile && npm run copyfiles","lint":"eslint . --ext=.ts"},"nyc":{"exclude":["test"],"extension":[".ts"]},"keywords":["bull","queue","adonis","adonisjs","adonis-js","adonis-bull","adonis-queue"],"bugs":{"url":"https://github.com/rocketseat/adonis-bull/issues"},"homepage":"https://github.com/rocketseat/adonis-bull#readme","publishConfig":{"access":"public","tag":"alpha"},"devDependencies":{"@adonisjs/ace":"^6.9.3","@adonisjs/application":"^2.0.0","@adonisjs/core":"^5.0.0-preview-rc-1.12","@adonisjs/fold":"^6.4.0","@adonisjs/logger":"^2.1.0","@adonisjs/mrm-preset":"^2.4.0","@types/node":"^14.6.1","@typescript-eslint/eslint-plugin":"^4.1.0","@typescript-eslint/parser":"^4.1.0","copyfiles":"^2.3.0","coveralls":"^3.0.7","eslint":"^6.6.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.18.2","eslint-plugin-node":"^10.0.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","japa":"^3.1.1","nyc":"^15.1.0","reflect-metadata":"^0.1.13","ts-node":"^9.0.0","typescript":"^3.9.7"},"repository":{"type":"git","url":"git+https://github.com/rocketseat/adonis-bull.git"},"peerDependencies":{"@adonisjs/core":">=5.0.0-preview"},"dependencies":{"bull-board":"^1.0.0-alpha.10","bullmq":"^1.9.0"},"types":"build/adonis-typings/index.d.ts","adonisjs":{"types":"@rocketseat/adonis-bull","providers":["@rocketseat/adonis-bull"],"commands":["@rocketseat/adonis-bull/build/commands"]},"gitHead":"27f451f4774e0f8279f18ad329ada6eb45e74e88","description":"<h1 align=\"center\">   <img width=\"275\" alt=\"Adonis Bull\" src=\"https://user-images.githubusercontent.com/16545335/71373449-f2146880-2595-11ea-8a8c-9f51384a3f22.png\"> </h1>","_id":"@ashokgelal/adonis-bull@0.2.2","_nodeVersion":"14.15.3","_npmVersion":"6.14.10","dist":{"integrity":"sha512-to77xUdztjGSrF5XMQkkEq/DyGxfoW7P9k2BIzFV0gNBynGt3Ebf/MopycEu01wg0SjTLZuaIsNQBPzjOHST1w==","shasum":"020a9c4fea75a1ac2fc115180b8d5fe1bcedd739","tarball":"https://registry.npmjs.org/@ashokgelal/adonis-bull/-/adonis-bull-0.2.2.tgz","fileCount":23,"unpackedSize":26147,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBc6rCRA9TVsSAnZWagAAmqYP/itzrlb2ICC45NCuJpcZ\nHWZJ7XXAgdhNM20B5ipbDVFDtvpn0AhkQoxc8JRvkm4HCVzd3ml77DDJGw4B\nPte6JFwVA5SH4qV3xPo0nDkpQMNxF9JUf0xP3Tdg4zyLOWeflL41SXLKGQKl\nD+YPqtxbsGWgf7vk4gzv1cuFdxwaLwm0msOTVBTkcBKt+1Z7aO42UkBoH+yK\nTb8fhg7oZH4iKPhfRcDMXt19KVxLoRwID0eTLrvaSVm0yblAtWbMLFvvFkpM\n7pjn0+K7zQ/B21d4PTCRVJfdXJnaI1fJEmIyam6VgVHnLqy0a1BlHxIVh8nU\n1STLqZGHHYxZA0IFCc2BiFDs4bb+jVY7IxWq/mQgFzNMTNLChN+1aJ2PgsC2\nQdq5ut8SFl+1ZPCpgrqh8gN/brtrey5HP2F4TWAZcUv5iGQn4CFvf2FwG8pZ\nsyua1rqdQbKDEAHfB/aWztRKXtYgW3kPBmu1gN+ErLW4cWAAjfeUWi49ruDm\nuei+GU0tt9fPftXFAH4hJd4iJRcz60/2VwxYXKAY9c2TQC4vgk2Cl9zkf5U/\nU0xktpNF4U+9M5SJcGnbW1CV8jjtd4LPsOOTtVLFWO0pGyWegNGZQuKhIgEO\nLkFHgoMxJVksDN0oqW6K+7DoHjkWOJunDtotEfdZBTB4tMFfxq8bffTURR/u\nFFdk\r\n=yCRo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+66EyDedK44pjXpCN5YDJUENUXxqZ2SMTDxWUJBQsCAIgUyUs+Djwahz/UHXytWpjvnrltpUhghcWj/NyweIIxqA="}]},"_npmUser":{"name":"ashokgelal","email":"ashokgelal@gmail.com"},"directories":{},"maintainers":[{"name":"ashokgelal","email":"ashokgelal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/adonis-bull_0.2.2_1610993323241_0.00146092287801447"},"_hasShrinkwrap":false},"0.2.3":{"name":"@ashokgelal/adonis-bull","version":"0.2.3","main":"build/providers/BullProvider.js","license":"MIT","scripts":{"test:local":"node japaFile.js","test":"nyc npm run test:local","coverage":"nyc report --reporter=text-lcov | coveralls","copyfiles":"copyfiles \"templates/**/*.txt\" build","compile":"tsc","build":"npm run compile && npm run copyfiles","lint":"eslint . --ext=.ts"},"nyc":{"exclude":["test"],"extension":[".ts"]},"keywords":["bull","queue","adonis","adonisjs","adonis-js","adonis-bull","adonis-queue"],"bugs":{"url":"https://github.com/rocketseat/adonis-bull/issues"},"homepage":"https://github.com/rocketseat/adonis-bull#readme","publishConfig":{"access":"public","tag":"alpha"},"devDependencies":{"@adonisjs/ace":"^6.9.3","@adonisjs/application":"^2.0.0","@adonisjs/core":"^5.0.0-preview-rc-1.12","@adonisjs/fold":"^6.4.0","@adonisjs/logger":"^2.1.0","@adonisjs/mrm-preset":"^2.4.0","@types/node":"^14.6.1","@typescript-eslint/eslint-plugin":"^4.1.0","@typescript-eslint/parser":"^4.1.0","copyfiles":"^2.3.0","coveralls":"^3.0.7","eslint":"^6.6.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.18.2","eslint-plugin-node":"^10.0.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","japa":"^3.1.1","nyc":"^15.1.0","reflect-metadata":"^0.1.13","ts-node":"^9.0.0","typescript":"^3.9.7"},"repository":{"type":"git","url":"git+https://github.com/rocketseat/adonis-bull.git"},"peerDependencies":{"@adonisjs/core":">=5.0.0-preview"},"dependencies":{"bull-board":"^1.0.0-alpha.10","bullmq":"^1.9.0"},"types":"build/adonis-typings/index.d.ts","adonisjs":{"types":"@ashokgelal/adonis-bull","providers":["@ashokgelal/adonis-bull"],"commands":["@ashokgelal/adonis-bull/build/commands"]},"readme":"<h1 align=\"center\">\n  <img width=\"275\" alt=\"Adonis Bull\" src=\"https://user-images.githubusercontent.com/16545335/71373449-f2146880-2595-11ea-8a8c-9f51384a3f22.png\">\n</h1>\n\n<p align=\"center\">\n  A <a href=\"https://github.com/OptimalBits/bull/\">Bull</a> provider for the Adonis framework. </br>\n  Adonis Bull provides an easy way to start using Bull. The fastest, most reliable, Redis-based queue for Node.\n</p>\n\n## Install\n\nYARN\n\n```\nyarn add @rocketseat/adonis-bull\n```\n\nNPM\n\n```\nnpm install @rocketseat/adonis-bull\n```\n\n\n## Setup\n\n`node ace invoke @ashokgelal/adonis-bull`\n\n## Use\n\nAdd the config file at `config/bull.ts`:\n\n```ts\nimport Env from '@ioc:Adonis/Core/Env'\nimport { BullConfig } from '@ioc:Rocketseat/Bull'\n\n\nconst bullConfig: BullConfig = {\n  connection: Env.get('BULL_CONNECTION', 'bull'),\n  connections: {\n    bull: {\n  \t  host: Env.get('BULL_REDIS_HOST'),\n  \t  port: Env.get('BULL_REDIS_PORT'),\n  \t  password: Env.get('BULL_REDIS_PASSWORD', ''),\n  \t  db: 0,\n  \t  keyPrefix: '',\n    },\n  }\n}\n\nexport default bullConfig\n```\n\nIn the above file you can define redis connections, there you can pass all `Bull` queue configurations described [here](https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queue).\n\n\nCreate a file with the `jobs` that will be processed at `start/jobs.ts`:\n\n```ts\nconst jobs = [\"App/Jobs/UserRegisterEmail\"]\n\nexport default jobs\n```\n\nOr use the magic way, it will declare all jobs for you:\n\n```ts\nimport { listDirectoryFiles } from '@adonisjs/ace'\nimport Application from '@ioc:Adonis/Core/Application'\nimport { join } from 'path'\n\n/*\n|--------------------------------------------------------------------------\n| Exporting an array of jobs\n|--------------------------------------------------------------------------\n|\n| Instead of manually exporting each file from the app/Jobs directory, we\n| use the helper `listDirectoryFiles` to recursively collect and export\n| an array of filenames.\n*/\nconst jobs = listDirectoryFiles(\n  join(Application.appRoot, 'app/Jobs'),\n  Application.appRoot\n).map((name) => {\n  return name\n    .replace(/^\\.\\/app\\/Jobs\\//, 'App/Jobs/')\n    .replace(/\\.(?:t|j)s$/, '')\n})\n\nexport default jobs\n```\n\nCreate a new preload file by executing the following ace command.\n\n```bash\nnode ace make:prldfile bull\n\n# ✔  create    start/bull.ts\n```\n\n```js\nimport Bull from '@ioc:Rocketseat/Bull'\n\nBull.process()\n  // Optionally you can start BullBoard:\n  .ui(9999); // http://localhost:9999\n  // You don't need to specify the port, the default number is 9999\n```\n\n## Creating your job\n\nCreate a new job file by executing the following ace command.\n\n```bash\nnode ace make:job userRegisterEmail\n\n# ✔  create    app/Jobs/UserRegisterEmail.ts\n```\n\n```ts\nimport { JobContract } from '@ioc:Rocketseat/Bull'\nimport Mail from '@ioc:Adonis/Addons/Mail'\n\nexport default class UserRegisterEmail implements JobContract {\n  public key = 'UserRegisterEmail'\n\n  public async handle(job) {\n    const { data } = job; // the 'data' variable has user data\n\n    await Mail.send(\"emails.welcome\", data, message => {\n      message\n        .to(data.email)\n        .from(\"<from-email>\")\n        .subject(\"Welcome to yardstick\");\n    });\n\n    return data;\n  }\n}\n```\n\nYou can override the default `configs`.\n\n```ts\n...\nimport { JobsOptions, QueueOptions, WorkerOptions, Job } from 'bullmq'\n\nexport default class UserRegisterEmail implements JobContract {\n  ...\n  public options: JobsOptions = {}\n\n  public queueOptions: QueueOptions = {}\n\n  public workerOptions: WorkerOptions = {}\n}\n```\n\n### Events\n\nYou can config the events related to the `job` to have more control over it\n\n```ts\n...\nimport Ws from 'App/Services/Ws'\n\nexport default class UserRegisterEmail implements JobContract {\n  ...\n\n  boot(queue) {\n    queue.on('complete', (job, result) => {\n      Ws\n        .getChannel('admin:notifications')\n        .topic('admin:notifications')\n        .broadcast('new:user', result)\n    })\n  }\n}\n```\n\n## Processing the jobs\n\n### Simple job\n\nYou can share the `job` of any `controller`, `hook` or any other place you might like:\n\n```ts\nimport User from 'App/Models/User'\nimport Bull from '@ioc:Rocketseat/Bull'\nimport Job from 'App/Jobs/UserRegisterEmail'\n\nexport default class UserController {\n  store ({ request, response }) {\n    const data = request.only(['email', 'name', 'password'])\n\n    const user = await User.create(data)\n\n\n    Bull.add(Job.key, user)\n  }\n}\n```\n\n### Scheduled job\n\nSometimes it is necessary to schedule a job instead of shooting it imediately. You should use `schedule` for that:\n\n```ts\nimport User from 'App/Models/User'\nimport ProductOnSale from 'App/Services/ProductOnSale'\nimport Bull from '@ioc:Rocketseat/Bull'\nimport Job from 'App/Jobs/UserRegisterEmail'\nimport parseISO from 'date-fns/parseISO'\n\nexport default class HolidayOnSaleController {\n  store ({ request, response }) {\n    const data = request.only(['date', 'product_list']) // 2020-11-06T12:00:00\n\n    const products = await ProductOnSale.create(data)\n\n    Bull.schedule(Job.key, products, parseISO(data.date))\n  }\n}\n```\n\nThis `job` will be sent only on the specific date, wich for example here is on November 15th at noon.\n\nWhen finishing a date, never use past dates because it will cause an error.\n\nother ways of using `schedule`:\n\n```ts\nBull.schedule(key, data, new Date(\"2019-11-15 12:00:00\"));\nBull.schedule(key, data, 60 * 1000); // 1 minute from now.\n```\n\nOr with a third party lib:\n\n```ts\nimport humanInterval from 'human-interval'\n\nBull.schedule(key, data, humanInterval(\"2 hours\")); // 2 hours from now\n```\n\n### Advanced jobs\n\nYou can use the own `Bull` configs to improve your job:\n\n```ts\nBull.add(key, data, {\n  repeat: {\n    cron: \"0 30 12 * * WED,FRI\"\n  }\n});\n```\n\nThis `job` will be run at 12:30 PM, only on wednesdays and fridays.\n\n### Exceptions\n\nTo have a bigger control over errors that might occur on the line, the events that fail can be manipulated at the file `app/Exceptions/Handler.ts`:\n\n```ts\nimport Sentry from 'App/Services/Sentry'\n\nimport Logger from '@ioc:Adonis/Core/Logger'\nimport HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'\n\nexport default class ExceptionHandler extends HttpExceptionHandler {\n  constructor () {\n    super(Logger)\n  }\n\n  async report(error, job) {\n    Sentry.configureScope(scope => {\n      scope.setExtra(job);\n    });\n\n    Sentry.captureException(error);\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"2fd525a05f73c6d64e1e1e7fc0b51ca79567662d","description":"<h1 align=\"center\">   <img width=\"275\" alt=\"Adonis Bull\" src=\"https://user-images.githubusercontent.com/16545335/71373449-f2146880-2595-11ea-8a8c-9f51384a3f22.png\"> </h1>","_id":"@ashokgelal/adonis-bull@0.2.3","_nodeVersion":"14.15.3","_npmVersion":"6.14.10","dist":{"integrity":"sha512-dwyMy4yHm2pN7baIzbE2hA5a2k7SAq0APpSrkNAEYjK7obQEwm3PuOtDXTJVu2kv4zhrQzrkucG6kRKk5QNxXg==","shasum":"485ea8a44691731c0a0a06cafc7fbe044f9dfdc0","tarball":"https://registry.npmjs.org/@ashokgelal/adonis-bull/-/adonis-bull-0.2.3.tgz","fileCount":23,"unpackedSize":26238,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBhVICRA9TVsSAnZWagAAM/YP/2h4y0pa3t0ZXzdf5Pjc\nvqXoTRqw/5CGl4/szJwV84ro85YBpY4zSxAL+HBcmn9HAVADHplOtY0+zJS2\n7jMITNmdIlMMdg87i0WkUvR+iDYsjn9dlMSmD2o8xrMvhoCdN+bAy7RV8Snj\n3GjcvRLSwQo13CDkXVkabBIDpxjQatbz6L6Ha6PQIB165jB/xhfNP52WaCCj\niK4hZD81BM+sbdHcsjdH31gTOjnwTj2oZf5uDpaMtcAPJwj2ziTfTMxgcdxp\nuxP1VLLt+arsgkL9kPQUvJabilckMPZg+Fh1o2SukJdDnVuDTY5psThlCJ9E\nrujz0FrqHYdRGPmu7fHlZpWy/qB9w9LWIvjiStM+gNrK6w+VPNHpbNhgCrAz\nb39C32HHrFdiRtsQLF/TDZ5EqRWpxJQ/r0dxDjA7TZKjbGVed+4Zif342MuK\nK//SC5nUeN/7HnjmeEvqu5TL1VPQ/m0cDUW37q9bp6KG1oTq2/gI1oNh7X3I\nUMi8GRnqwcJt5hGzrKNJ8DZsxfMZ1xcwV7rsKt0ArUCWnTffxGCE+NskpN8V\no3rMoaifQPbWd3wUbL7nlx7IvhwhrPqostxjdhd95SBB4I1YZ9iiv/qRlG4M\ndJQ//4brZBtDImu6iQjZU3AQXchVpJHTF6EPI5K2LTv/EgMxJ8a646OSoPXW\nNpv4\r\n=ClTS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGzIhkzi3ykrrgRQSn+oUdV4DKcaWwQFpFDVRaVby8mhAiEAtPKp+/hU3UpI/vIbddKcPWbfqFFKiQEDHOhrdRvGWek="}]},"_npmUser":{"name":"ashokgelal","email":"ashokgelal@gmail.com"},"directories":{},"maintainers":[{"name":"ashokgelal","email":"ashokgelal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/adonis-bull_0.2.3_1611011399977_0.35175495147136404"},"_hasShrinkwrap":false},"0.2.4":{"name":"@ashokgelal/adonis-bull","version":"0.2.4","main":"build/providers/BullProvider.js","license":"MIT","scripts":{"test:local":"node japaFile.js","test":"nyc npm run test:local","coverage":"nyc report --reporter=text-lcov | coveralls","copyfiles":"copyfiles \"templates/**/*.txt\" build","compile":"tsc","build":"npm run compile && npm run copyfiles","lint":"eslint . --ext=.ts"},"nyc":{"exclude":["test"],"extension":[".ts"]},"keywords":["bull","queue","adonis","adonisjs","adonis-js","adonis-bull","adonis-queue"],"bugs":{"url":"https://github.com/rocketseat/adonis-bull/issues"},"homepage":"https://github.com/rocketseat/adonis-bull#readme","publishConfig":{"access":"public","tag":"alpha"},"devDependencies":{"@adonisjs/ace":"^6.9.3","@adonisjs/application":"^2.0.0","@adonisjs/core":"^5.0.0-preview-rc-1.12","@adonisjs/fold":"^6.4.0","@adonisjs/logger":"^2.1.0","@adonisjs/mrm-preset":"^2.4.0","@types/node":"^14.6.1","@typescript-eslint/eslint-plugin":"^4.1.0","@typescript-eslint/parser":"^4.1.0","copyfiles":"^2.3.0","coveralls":"^3.0.7","eslint":"^6.6.0","eslint-config-standard":"^14.1.0","eslint-plugin-import":"^2.18.2","eslint-plugin-node":"^10.0.0","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","japa":"^3.1.1","nyc":"^15.1.0","reflect-metadata":"^0.1.13","ts-node":"^9.0.0","typescript":"^3.9.7"},"repository":{"type":"git","url":"git+https://github.com/rocketseat/adonis-bull.git"},"peerDependencies":{"@adonisjs/core":">=5.0.0-preview"},"dependencies":{"bull-board":"^1.0.0-alpha.10","bullmq":"^1.9.0"},"types":"build/adonis-typings/index.d.ts","adonisjs":{"types":"@ashokgelal/adonis-bull","providers":["@ashokgelal/adonis-bull"],"commands":["@ashokgelal/adonis-bull/build/commands"]},"readme":"<h1 align=\"center\">\n  <img width=\"275\" alt=\"Adonis Bull\" src=\"https://user-images.githubusercontent.com/16545335/71373449-f2146880-2595-11ea-8a8c-9f51384a3f22.png\">\n</h1>\n\n<p align=\"center\">\n  A <a href=\"https://github.com/OptimalBits/bull/\">Bull</a> provider for the Adonis framework. </br>\n  Adonis Bull provides an easy way to start using Bull. The fastest, most reliable, Redis-based queue for Node.\n</p>\n\n## Install\n\nYARN\n\n```\nyarn add @rocketseat/adonis-bull\n```\n\nNPM\n\n```\nnpm install @rocketseat/adonis-bull\n```\n\n\n## Setup\n\n`node ace invoke @ashokgelal/adonis-bull`\n\n## Use\n\nAdd the config file at `config/bull.ts`:\n\n```ts\nimport Env from '@ioc:Adonis/Core/Env'\nimport { BullConfig } from '@ioc:Rocketseat/Bull'\n\n\nconst bullConfig: BullConfig = {\n  connection: Env.get('BULL_CONNECTION', 'bull'),\n  connections: {\n    bull: {\n  \t  host: Env.get('BULL_REDIS_HOST'),\n  \t  port: Env.get('BULL_REDIS_PORT'),\n  \t  password: Env.get('BULL_REDIS_PASSWORD', ''),\n  \t  db: 0,\n  \t  keyPrefix: '',\n    },\n  }\n}\n\nexport default bullConfig\n```\n\nIn the above file you can define redis connections, there you can pass all `Bull` queue configurations described [here](https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queue).\n\n\nCreate a file with the `jobs` that will be processed at `start/jobs.ts`:\n\n```ts\nconst jobs = [\"App/Jobs/UserRegisterEmail\"]\n\nexport default jobs\n```\n\nOr use the magic way, it will declare all jobs for you:\n\n```ts\nimport { listDirectoryFiles } from '@adonisjs/ace'\nimport Application from '@ioc:Adonis/Core/Application'\nimport { join } from 'path'\n\n/*\n|--------------------------------------------------------------------------\n| Exporting an array of jobs\n|--------------------------------------------------------------------------\n|\n| Instead of manually exporting each file from the app/Jobs directory, we\n| use the helper `listDirectoryFiles` to recursively collect and export\n| an array of filenames.\n*/\nconst jobs = listDirectoryFiles(\n  join(Application.appRoot, 'app/Jobs'),\n  Application.appRoot\n).map((name) => {\n  return name\n    .replace(/^\\.\\/app\\/Jobs\\//, 'App/Jobs/')\n    .replace(/\\.(?:t|j)s$/, '')\n})\n\nexport default jobs\n```\n\nCreate a new preload file by executing the following ace command.\n\n```bash\nnode ace make:prldfile bull\n\n# ✔  create    start/bull.ts\n```\n\n```js\nimport Bull from '@ioc:Rocketseat/Bull'\n\nBull.process()\n// Optionally you can start BullBoard:\nBull.ui(9999); // http://localhost:9999\n// You don't need to specify the port, the default number is 9999\n```\n\n## Creating your job\n\nCreate a new job file by executing the following ace command.\n\n```bash\nnode ace make:job userRegisterEmail\n\n# ✔  create    app/Jobs/UserRegisterEmail.ts\n```\n\n```ts\nimport { JobContract } from '@ioc:Rocketseat/Bull'\nimport Mail from '@ioc:Adonis/Addons/Mail'\n\nexport default class UserRegisterEmail implements JobContract {\n  public key = 'UserRegisterEmail'\n\n  public async handle(job) {\n    const { data } = job; // the 'data' variable has user data\n\n    await Mail.send(\"emails.welcome\", data, message => {\n      message\n        .to(data.email)\n        .from(\"<from-email>\")\n        .subject(\"Welcome to yardstick\");\n    });\n\n    return data;\n  }\n}\n```\n\nYou can override the default `configs`.\n\n```ts\n...\nimport { JobsOptions, QueueOptions, WorkerOptions, Job } from 'bullmq'\n\nexport default class UserRegisterEmail implements JobContract {\n  ...\n  public options: JobsOptions = {}\n\n  public queueOptions: QueueOptions = {}\n\n  public workerOptions: WorkerOptions = {}\n}\n```\n\n### Events\n\nYou can config the events related to the `job` to have more control over it\n\n```ts\n...\nimport Ws from 'App/Services/Ws'\n\nexport default class UserRegisterEmail implements JobContract {\n  ...\n\n  boot(queue) {\n    queue.on('complete', (job, result) => {\n      Ws\n        .getChannel('admin:notifications')\n        .topic('admin:notifications')\n        .broadcast('new:user', result)\n    })\n  }\n}\n```\n\n## Processing the jobs\n\n### Simple job\n\nYou can share the `job` of any `controller`, `hook` or any other place you might like:\n\n```ts\nimport User from 'App/Models/User'\nimport Bull from '@ioc:Rocketseat/Bull'\nimport Job from 'App/Jobs/UserRegisterEmail'\n\nexport default class UserController {\n  store ({ request, response }) {\n    const data = request.only(['email', 'name', 'password'])\n\n    const user = await User.create(data)\n\n\n    Bull.add(Job.key, user)\n  }\n}\n```\n\n### Scheduled job\n\nSometimes it is necessary to schedule a job instead of shooting it imediately. You should use `schedule` for that:\n\n```ts\nimport User from 'App/Models/User'\nimport ProductOnSale from 'App/Services/ProductOnSale'\nimport Bull from '@ioc:Rocketseat/Bull'\nimport Job from 'App/Jobs/UserRegisterEmail'\nimport parseISO from 'date-fns/parseISO'\n\nexport default class HolidayOnSaleController {\n  store ({ request, response }) {\n    const data = request.only(['date', 'product_list']) // 2020-11-06T12:00:00\n\n    const products = await ProductOnSale.create(data)\n\n    Bull.schedule(Job.key, products, parseISO(data.date))\n  }\n}\n```\n\nThis `job` will be sent only on the specific date, wich for example here is on November 15th at noon.\n\nWhen finishing a date, never use past dates because it will cause an error.\n\nother ways of using `schedule`:\n\n```ts\nBull.schedule(key, data, new Date(\"2019-11-15 12:00:00\"));\nBull.schedule(key, data, 60 * 1000); // 1 minute from now.\n```\n\nOr with a third party lib:\n\n```ts\nimport humanInterval from 'human-interval'\n\nBull.schedule(key, data, humanInterval(\"2 hours\")); // 2 hours from now\n```\n\n### Advanced jobs\n\nYou can use the own `Bull` configs to improve your job:\n\n```ts\nBull.add(key, data, {\n  repeat: {\n    cron: \"0 30 12 * * WED,FRI\"\n  }\n});\n```\n\nThis `job` will be run at 12:30 PM, only on wednesdays and fridays.\n\n### Exceptions\n\nTo have a bigger control over errors that might occur on the line, the events that fail can be manipulated at the file `app/Exceptions/Handler.ts`:\n\n```ts\nimport Sentry from 'App/Services/Sentry'\n\nimport Logger from '@ioc:Adonis/Core/Logger'\nimport HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'\n\nexport default class ExceptionHandler extends HttpExceptionHandler {\n  constructor () {\n    super(Logger)\n  }\n\n  async report(error, job) {\n    Sentry.configureScope(scope => {\n      scope.setExtra(job);\n    });\n\n    Sentry.captureException(error);\n  }\n}\n```\n","readmeFilename":"README.md","gitHead":"e7aff16ad70539b91a0aa469e4165fee75bc119c","description":"<h1 align=\"center\">   <img width=\"275\" alt=\"Adonis Bull\" src=\"https://user-images.githubusercontent.com/16545335/71373449-f2146880-2595-11ea-8a8c-9f51384a3f22.png\"> </h1>","_id":"@ashokgelal/adonis-bull@0.2.4","_nodeVersion":"14.15.3","_npmVersion":"6.14.10","dist":{"integrity":"sha512-5V82GJ6cPgLCg0/EVMxzffmUhGJkQLS4nwqvg4h2zDido7g9m+IHI8LFU/3rlKyEpnT7ZwlIi9UE17OCUCjqAg==","shasum":"735eb8359542ccba2d498bd86ba497f23cc8094f","tarball":"https://registry.npmjs.org/@ashokgelal/adonis-bull/-/adonis-bull-0.2.4.tgz","fileCount":23,"unpackedSize":26236,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBhfYCRA9TVsSAnZWagAAH0AQAJHLgCC7SXEy70YMK1Ak\ncdA1lwFFj2KuttT9hJVLCCnX1brsWDxzWadRcYAD+MOZC0ClKqAjyaCOy3CF\nrdK0BboyTLKzkiwySCQBApLfGI/xFBij1uC7rFPSnU8Sk7ZOvhIVVHYXETeX\n/UHGqsthE15jlvhYFzaWVjHS0v4dJmQs/5TMwUPV9PXTVwIcU0PekrqtZwuG\nELaYATyFuuQFjg+cYNMoLIJyPBcEG0R7MrRiZapoMmq4VwTtM8jNef4hoc52\njJ3pDXvoPQSHojn0YBSf0/hPktI9fgyUU3+GZmNNwBs9M5MDo/KcTVYk52zH\nhb9btt0noJq53fRrpt0wvuMmo5OQ8WP54y+02Qywl68vw1+qMeb5rUqheSab\n/Jl8+pJ4ogghKQxy4vpMkll1vnWsusnJfz4pvczaAwUXD7Gie9f/QSbBQCXs\nESohHXgx6o8tANgmI3/1x68MvlZTVPVRT1Ebxo/Zt7T5Yud9yFY5fjDclW2K\nMwMpoVq6UHO6O1KVil2SnMY5zXkLkDh0A6OsBG5kdyOm6u8EY2Y2eRn4k9cN\nnXH9IU28i7OPfv2teM/85W7EAtdvUnK7ZF0zP39wa0PIHIvCDn44sjadSljm\nNQoWOz4WVH3/xCz1lqvi5Tizh55KqWqzdOPwlak0SW5CyvPkgpFfhds62UNT\nuXqi\r\n=7gM5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAGGfBGzJU8pC9GtRzBOIH5gjLFOlhG6/04QnUyNPO+/AiEAktltBeS6KHUHhFUpNgOkBw1KsI3dRgzx5mmyLbJtLZk="}]},"_npmUser":{"name":"ashokgelal","email":"ashokgelal@gmail.com"},"directories":{},"maintainers":[{"name":"ashokgelal","email":"ashokgelal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/adonis-bull_0.2.4_1611012056241_0.18571298303524486"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-18T18:08:43.185Z","0.2.2":"2021-01-18T18:08:43.382Z","modified":"2022-04-04T15:45:56.755Z","0.2.3":"2021-01-18T23:10:00.085Z","0.2.4":"2021-01-18T23:20:56.359Z"},"maintainers":[{"name":"ashokgelal","email":"ashokgelal@gmail.com"}],"description":"<h1 align=\"center\">   <img width=\"275\" alt=\"Adonis Bull\" src=\"https://user-images.githubusercontent.com/16545335/71373449-f2146880-2595-11ea-8a8c-9f51384a3f22.png\"> </h1>","homepage":"https://github.com/rocketseat/adonis-bull#readme","keywords":["bull","queue","adonis","adonisjs","adonis-js","adonis-bull","adonis-queue"],"repository":{"type":"git","url":"git+https://github.com/rocketseat/adonis-bull.git"},"bugs":{"url":"https://github.com/rocketseat/adonis-bull/issues"},"license":"MIT","readme":"","readmeFilename":""}