{"name":"@eggjs/tegg-background-task","version":"3.2.2","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@3.2.2","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"0e597ee2881fd225a993ff2ac8b791d9b40b05f8","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-3.2.2.tgz","fileCount":7,"integrity":"sha512-CzDBBKiDFMU+G1RjzCui/OZt8bJtO4sEPMU3gw2bEdxe4DRxnblUk067TjypQwx+Hd85qwmnW1gAx7R3jYm4Gw==","signatures":[{"sig":"MEUCIFzXCvxPPQkx4uW33nWzFGnqnZazL7VCyYabJllH7CqsAiEAlkjj8eoZJ2IqWINWk/caegW4HZhLW7TdnPBMZtST+1Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11804,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjt4z3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqFUQ//atf3smlK34VokNugmNSjd6g5Rhyw7hNUabDGXWT3SCHlLM75\r\nZ3QsmLAAjFx0tRCW9Xkqv7GhcS3q3fXu0K4C2nJnO6LeZeJW17OTJ1aQvXX2\r\nizRsLpu+jNuGznoIqg2rMRe87lz07UOGM4Y8hsZUzSeBddg9ZPnW66WtE4U5\r\nKBJhY0oSWI7oKpBD2LHqtB6eJaZY6NZTW3f0UzF+cNcGXG4KwsFmx48MaFOT\r\nEpTXIJ+O59jSat8wdwCMPu8bTkZoFcNGij9RZ4RdFrZEVjmM5mDWzDblUzLk\r\npYfAInruM23kVOTbdwehjozPwDUulBJBT2KgtGNECuVybWs7GRfRUHO0B2qp\r\nH5kT1PjX52sp4pbYoa9SPVkdEwU21O8QmOxaTs/I+omsPgiyZ/gCmipPTJai\r\nTrBOyBfFiVzqQtWFDy0E42Acwb9nVr7Lj99+SRCcn/9w1D/lvqCDGBwYY/Po\r\n1xg7KI5+QyFnmuy3CYpRetSqGdIldXAmHXAjiHXQSGcj8KhqITdVhFicx08f\r\nGUFHT/a488rXxSaA/FUC60dt3X2M3SpJgDVnjY2Nf52s4RJl/5lDcf2L5L0t\r\n3Zjr0sStb1iJSBxG8z2hrSW45ucL8F8W8wq8vqFLm+zQeu95ZXqC5/YRVX4d\r\n+k2F35wzaK7Tjpos3spKJ2Yv3KGg3q/Cfv4=\r\n=FB8s\r\n-----END PGP SIGNATURE-----\r\n","size":4793,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-3.2.2.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"1db4e5320a0ea19b450df7d99ab7939f3ad48f6e","scripts":{"tsc":"npm run clean && tsc -p ./tsconfig.json","test":"cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha","clean":"tsc -b --clean","tsc:pub":"npm run clean && tsc -p ./tsconfig.pub.json","prepublishOnly":"npm run tsc:pub"},"typings":"dist/index.d.ts","_npmUser":{"name":"killagu","email":"killa07071201@gmail.com"},"repository":{"url":"git+ssh://git@github.com/eggjs/tegg.git","type":"git","directory":"core/background-task"},"_npmVersion":"lerna/6.4.0/node@v16.18.1+x64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"16.18.1","dependencies":{"@eggjs/tegg-runtime":"^3.2.2","@eggjs/core-decorator":"^3.2.2","@eggjs/tegg-lifecycle":"^3.2.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^3.9.1","mz-modules":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_3.2.2_1672973559633_0.5254450967409456","host":"s3://npm-registry-packages"},"readme":"# `@eggjs/tegg-background-task`\n\n## install\n```sh\nnpm i --save @eggjs/tegg-background-task\n```\n\n## Usage\n\n```ts\nimport { BackgroundTaskHelper } from '@eggjs/tegg-background-task';\n\n@ContextProto()\nexport default class BackgroundService {\n  @Inject()\n  private readonly backgroundTaskHelper:BackgroundTaskHelper\n\n  async backgroundAdd() {\n    this.backgroundTaskHelper.run(async () => {\n      // do the background task\n    });\n  }\n}\n```\n\n## Background\n\ntegg release the request context after request is done. So use the `process.nextTick`, `setTimeout`, `setInterval` in request is not safe.\nPlease use the `backgroundTaskHelper`, the release process will wait all the background tasks are done.\n\n## Timeout\n\nThe release process will wait tasks done, but not forever. The default timeout is 5s, if task will cost more than 5s, two ways to resolve\n- use the `SingletonProto` to do the work, `SingletonProto` never release\n- set longer timeout to `backgroundTaskHelper.timeout`\n\n","publish_time":1672973559839,"maintainers":[{"name":"akitasummer","email":"644171127@qq.com"},{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"gemwuu","email":"gemwuu@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"wanghx","email":"whxaxes@gmail.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"mansonchor.zzw","email":"mansonchor1987@gmail.com"},{"name":"hubcarl","email":"hubcarl@126.com"}],"_cnpm_publish_time":1672973559839,"dist-tags":{"alpha":"3.57.15-alpha.0","beta":"3.73.0-beta.1","beta-v3":"3.74.0-beta.3","latest":"3.88.1"}}