{"_id":"@autotelic/fastify-bee-queue","_rev":"2-9936382d6ec5d48cce9d87bdf32e5d1b","name":"@autotelic/fastify-bee-queue","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@autotelic/fastify-bee-queue","version":"0.0.1","description":"Fastify plugin for Bee-queue Integration","main":"index.js","directories":{"test":"test"},"scripts":{"test":"c8 --100 ava","lint":"standard","fix":"npm run lint -- --fix","validate":"npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-bee-queue.git"},"keywords":["fastify","redis","bee-queue","plugin","queue"],"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"license":"MIT","bugs":{"url":"https://github.com/autotelic/fastify-bee-queue/issues"},"homepage":"https://github.com/autotelic/fastify-bee-queue#readme","dependencies":{"bee-queue":"^1.4.0","fastify-plugin":"^3.0.0"},"devDependencies":{"ava":"^3.15.0","c8":"^7.10.0","fastify":"^3.0.0","fastify-cli":"^2.5.1","fastify-redis":"^4.3.3","lint-staged":"^12.1.2","sinon":"^12.0.1","standard":"^16.0.3","throng":"^5.0.0"},"lint-staged":{"*.{js,jsx}":["npm run fix"]},"gitHead":"c4cdcad2be2fef02eea785643c78d97ab068d7e9","_id":"@autotelic/fastify-bee-queue@0.0.1","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"integrity":"sha512-NNYIhzsSb/b650S2XQR+O9yA+2cAzdSGdaffzPyMBtfvQpnIwcqh0e1ecEwa0IEYAMjFdn+O+Hb7ZGcwtiVrIw==","shasum":"0bf8a587f2b69e74c25ac6be10c7972dc8c8ebae","tarball":"https://registry.npmjs.org/@autotelic/fastify-bee-queue/-/fastify-bee-queue-0.0.1.tgz","fileCount":25,"unpackedSize":23145,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhqAnQCRA9TVsSAnZWagAAzRwP/iKzN9kihRrxxkyHQahv\nbg7Fe0TpfJSsxwEl0Pdn+Yfki6htQg+kvaIim0x3vz57THoRcbshHEiz4TPr\nZ4QuMDpYulE2NuaIqwXddcJ6oBsxkohp1KRlBa4f7A3+bnmR59wUuqDGW3tM\n1nu7Am62Rxb4tdyY+qzXkmGA8bXnzKy6/dYGyEKAsbauH2HDYgYYKqCdV55v\n0e0G4MvTeLr6Zmt9UfTQ9yFEw5AQOq9YGJ8JjgcNMjftl02RtxQMfh1nSEG3\nN8KpR+vwi0D/sAQL/D68G3T1fcoVLZFdLbs88bE04CxnKpi4VsdwcZXThhre\nWKsJZ0iPJJzK6yz8bxMl+ELk2yHlbnmBB5mQv1NJB1wfTir46U9gfOxnsGjP\n6VkgouRJYAocuJaxbVWvqQIF4VtgWsFXf2AKPvBleqg+GujYdXwub/A54FR+\nRs/Ic3EjRxb1++4abS4WL4gRWnagQq69vUxIy3U+1gWlfRM+Sn4PgsBqtf/a\nn57+o0fu/rxpFw2pG4Wb59EVxjBovl36qWXu6P0GU99+ZKM6P6sill0RDaYl\nymEl4UzfZImFGX6cfv6yaljymaIseqvJinnaHqSDJsmIFRnmCKNXCa8AYcHi\nnmfqH9H2q1czPaDbsE6tD+hVuhCleqC4q1H4XnYWbS720mrsQYXya/ymtGHS\nPqng\r\n=b8Sx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDGLnI1BQy8TuraMEyePFFSxNXLDBTJxIdsO5A6r/0MjAiA26bRaBGmg40kL48TH2rU2L+lVpDLdceMYP62qGhXEEg=="}]},"_npmUser":{"name":"autotelic","email":"info+npm@autotelic.com"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fastify-bee-queue_0.0.1_1638402512489_0.419860735484477"},"_hasShrinkwrap":false},"0.1.0":{"name":"@autotelic/fastify-bee-queue","version":"0.1.0","description":"Fastify plugin for Bee-queue Integration","main":"index.js","directories":{"test":"test"},"scripts":{"test":"c8 --100 ava","lint":"standard","fix":"npm run lint -- --fix","validate":"npm run lint && npm run test"},"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-bee-queue.git"},"keywords":["fastify","redis","bee-queue","plugin","queue"],"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"license":"MIT","bugs":{"url":"https://github.com/autotelic/fastify-bee-queue/issues"},"homepage":"https://github.com/autotelic/fastify-bee-queue#readme","dependencies":{"bee-queue":"^1.4.0","fastify-plugin":"^3.0.0"},"devDependencies":{"ava":"^3.15.0","c8":"^7.10.0","fastify":"^3.0.0","fastify-cli":"^2.5.1","fastify-redis":"^4.3.3","lint-staged":"^12.1.2","sinon":"^12.0.1","standard":"^16.0.3","throng":"^5.0.0"},"lint-staged":{"*.{js,jsx}":["npm run fix"]},"gitHead":"cac2292de212dab3903663b6367a22c34ecfaec0","_id":"@autotelic/fastify-bee-queue@0.1.0","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"integrity":"sha512-Ui/gd+dgrb6bjn67g5lzpIBlmCp2OOMosWS0Zbiz20A+qh1D8AKPC0WQr+EvpKRnmCFmNow/S5K83Ba1fH4Qaw==","shasum":"db513a396ba1ac81794128fc06015d8fd5e20aae","tarball":"https://registry.npmjs.org/@autotelic/fastify-bee-queue/-/fastify-bee-queue-0.1.0.tgz","fileCount":25,"unpackedSize":23145,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhrkB4CRA9TVsSAnZWagAAsRYP/RkOjQ5w6QgKrIwyeYhM\nztPcLtbvGADlslW0Se8yPIji95HHAlUF2m9XkPh174v4xh5g1gkJfirxOYb2\nxXnuRU/6RYGUtiwq5YQsmzoniMa2eLzXwDP7Fk8hUMPwnDBBY9ZaEfUJ8v9X\nJkmzRpz6ruMT5s4+0JoQom8qzwknlMDNCSUf7H9N90SdWYHmbR7ppSQ3vnwB\nHMoqG5XQEzIfkiyjlrvf6SXcbn3XRzrd0HykRfwbVV4thXWP2/05MrELVJve\nzfB/VjNZZGx+56/y/lj5gBvo4bmk97f39fmrnJcBggt+SXVCWhM6X81pGsoZ\nVO96flBMDWRr7TLlL6THliLkV1nxP386ToatRNLlBFQsfFJl97Ap366Htjcp\nKgfWfENu8jHwLdyKUxNVQkqukyrvS3yUQqLWOQBF4bhGyd0ClURcFY4QUBCo\nX0DxL2P6OwMuhbIwFvLQYb9zYGt1G5ZbV8gZthOPo6vUBcmKjG+AkXNVIB2b\nxrieCYfhF4HAmNGIIk0ylWzeaMXSzBY8eSxq7j9Z26YWIkQWytumLdjAptEy\nYHS98wWtDYKbk7m0x4jt8+z0uw/HuMCTdRaOcKtHFH8SPN+V9G+51NAUHsBA\n285KW3BF/QincaacPpbLbnv/nKvgNqJ2u+KA+6kfErmLtVWb4pMAskj0xWxq\ng7hM\r\n=ph2C\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfmnm7Ueft+HcG9spBm0HggNzNnenTIQVMashR4x3ZoAIgK2hljyjqr5NkEHaHPE9B0o/Q0w6Ak1xzToNOFBUdQH8="}]},"_npmUser":{"name":"autotelic","email":"info+npm@autotelic.com"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fastify-bee-queue_0.1.0_1638809720415_0.18759550532703217"},"_hasShrinkwrap":false}},"time":{"created":"2021-12-01T23:48:32.441Z","0.0.1":"2021-12-01T23:48:32.619Z","modified":"2022-04-04T16:40:47.680Z","0.1.0":"2021-12-06T16:55:20.811Z"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"description":"Fastify plugin for Bee-queue Integration","homepage":"https://github.com/autotelic/fastify-bee-queue#readme","keywords":["fastify","redis","bee-queue","plugin","queue"],"repository":{"type":"git","url":"git+https://github.com/autotelic/fastify-bee-queue.git"},"author":{"name":"Autotelic Development Ltd","email":"info@autotelic.com"},"bugs":{"url":"https://github.com/autotelic/fastify-bee-queue/issues"},"license":"MIT","readme":"# fastify-bee-queue\n\nA plugin for implementing [Bee Queue](https://github.com/bee-queue/bee-queue)\njob/task queues in fastify applications.\n\n## Install\n\n```\nnpm i @autotelic/fastify-bee-queue\n```\n\n## Usage\n\n```js\n// Server.js\nconst Fastify = require('fastify')\nconst { fastifyBeeQueue } = require('@autotelic/fastify-bee-queue')\nconst fastify = Fastify()\n\nconst QUEUE_NAME = 'some-queue-name'\n\nfastify.register(fastifyBeeQueue, {\n  redis: 'redis://127.0.0.1',\n})\n\nfastify.register(async (fastify, opts) => {\n  // Create a Queue instance. By default each Queue will create a connection\n  // to redis.\n  await fastify.bq.createProducer(QUEUE_NAME)\n})\n\nfastify.post('/queue', async (request, response) => {\n  const { queues } = fastify.bq\n  // Access the Queue Instance\n  const q = queues[QUEUE_NAME]\n  const { body } = request\n  const { x, y } = body\n  // Create and save a Job in the Queue.\n  q.createJob({ x: parseInt(x), y: parseInt(y) }).save()\n  response.send('Scheduled Job')\n})\n\nfastify.listen(3000)\n\n// worker.js\n\n// The workerBees function provides a convenience wrapper for creating\n// and configuring Queue instances which will process jobs.\nconst { workerBees } = require('@autotelic/fastify-bee-queue')\nconst QUEUE_NAME = 'some-queue-name'\n\n// The worker Queue instances to be created.\nconst workers = [\n  {\n    name: QUEUE_NAME,\n    processor: async (job) => job.data.x + job.data.y,\n    options: {}\n  }\n]\n\n// Base configuration applied to all worker Queues.\nconst queueOptions = {\n  redis: 'redis://127.0.0.1',\n}\n\nconst { start } = workerBees({ workers, queueOptions })\n\n// Start the workers and begin processing jobs. Start also returns a promise\n// which resolves to an array of the running worker Queues.\nconst queues = await start()\n```\n## Examples\n\nWe provide the following usage examples and recipes:\n- [basic](./examples/basic/README.md)\n- [shared redis connection](./examples/shared-redis-connection/README.md)\n- [optimizing concurrency](./examples/optimizing-concurrency/README.md)\n\n## API\n\n### Plugin\n\n#### Options\n\n- `namespace`: The namespace that the plugin decorators will be added to.\nDefaults to `bq`\n\nAll remaining options will be passed to the Queue instances when they are created.\nFor more details please refer to the Bee Queue [settings documentation](https://github.com/bee-queue/bee-queue#settings)\n\n#### Decorators\n\nThe plugin exposes the following as decorators under the configured namespace.\nBy default this namespace is `bq`\n\n##### `createProducer: (name: string, opts: Object)`\n\ncreates a \"Producer\" Queue instance. producer Queues are unable to process jobs or\nreceive messages. They are primarily used to add jobs to a Queue.\n\n`name`: The name of the Queue instance. This is also the lookup key in the queues\nobject.\n\n`opts`: The Queue instance settings.\n\n##### `create: (name: string, opts: Object)`\n\nCreates a worker Queue instance. This queue can process jobs and send/receive messages.\n\n`name`: The name of the Queue instance. This is also the lookup key in the queues\nobject.\n\n`opts`: The Queue instance settings.\n\n##### `queues: Object`\n\nThe key/value store where all created Queue instances are stored. They may be accessed by queue name. The plugin will throw an error if duplicate keys are added\nto the queues object.\n\n### Workers\n\nUtilities for creating bee-queue workers.\n\n#### `workerBees: (configuration: Object) => Object<{ start: () => Promise<Array[Queues]> }>`\n\nCreates and starts bee-queue workers for processing jobs.\n\n- `configuration` The configuration object for worker bees, expects fields:\n  - `queueOptions`: The Queue [settings](https://github.com/bee-queue/bee-queue#settings)) which will be applied to all worker Queues.\n  - `workers: Object` - A worker configuration Object which contains fields:\n    - `name: string` - The Name of the queue\n    - `processor: () => Promise<Any>` - An async method to process jobs from the queue.\n    - `options: Object` - The Queue settings which will be applied only to this worker Queue.\n\n\n## Github Actions/Workflows\n\n#### Triggering a Release\n\n* Trigger the release workflow via release tag\n  ```sh\n  git checkout main && git pull\n  npm version { minor | major | path }\n  git push --follow-tags\n  ```\n\n## License\n\nThis project is covered under the [MIT](./LICENSE) license.\n","readmeFilename":"README.md"}