{"name":"@eggjs/tegg-background-task","version":"3.2.1","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@3.2.1","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"6e8fe04cb8e1f47bf9b51aaea630c14eeb2d0dc5","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-3.2.1.tgz","fileCount":7,"integrity":"sha512-EQiW/vsox41d0cbhMTXI46lv08DPp4XKi5UPJ5d36ToYbXMlpQxfWHLWoHOc5L7JWzdKfiIP1Dpl/4vlhcC+zA==","signatures":[{"sig":"MEQCIFequyVmCBpWDY6bumiWlxGGmvgQ1QEMWu83Z8iatI5YAiAWMyqWUtHZCEyq7y7KS4kH1WklIKTXxxR82MBew2dQnw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11749,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrFWpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqd3w/6A4IP9qKeqhnnoz2J8okcYtmBNk9Gz8BO3Yafn6bt43AyOaD5\r\nK4ecZs4HENWr6vcuazn2qwfcG4TtWGXsEgvuTetR34D7Jso1KueySGC4A6nH\r\nkPOvOEAMqaWYD6d0RyUXr0bDH4GLSOPfcXt9ucLRU/ztXqs1OwzvFtKJUMzb\r\nzmGRwL0rRwc8pMQlkBIdJQt6P1KjsS1ynb/Zoshzi5kCYauiloqzQJ1rJ4Ur\r\nbef2447Vo/9P1o3wowKpBbuz2Ym9dgVXqjoVLbm3J1wNqg647MGwl6RFUjEU\r\nI3TKzwiE1xeifvH+bt6OIw88KsoVP0B91v/qBYyGTfcL2aGet1gUalanANzW\r\nlLDn1TYOeDQn71THaKH7KQ0v1NQYiRQglqJhRtvchyD1pR0Ztxa8qyPWdRQT\r\n+00Sz/CK7WgcVb1Z7zD6+WbpRuiZ+vPrQyMm89fEh8BimlzPqw7k5Ubzh+q+\r\nMOgKnMYTvWMR0I+WnRPX/oP+YwI9MdMsZMx4MZttB2o7joOj4RgFBnoDYUpu\r\np2h+gAcVyZPu82qj5NO4JdzPC+AXxXcv08I9BFB/eSCG46tsCJUtUJTBbDwp\r\nyzTfUMqP80ZfRS6kogYtCar1HV4+fTxl1yUguWWitU6oOtdHXfzuhjWizNVi\r\nPh2mGOCvJ0J1h8zHezFVKAj8P9FYuyxndcI=\r\n=6XIK\r\n-----END PGP SIGNATURE-----\r\n","size":4761,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-3.2.1.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"5591645a1e1e58b112cbb130d4700e1560cbfa62","scripts":{"tsc":"npm run clean && tsc -p ./tsconfig.json","autod":"autod","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.3.0/node@v16.18.1+x64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"16.18.1","dependencies":{"@eggjs/tegg-runtime":"^3.2.1","@eggjs/core-decorator":"^3.1.0","@eggjs/tegg-lifecycle":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^3.9.1","mz-modules":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_3.2.1_1672238505604_0.8907737290110211","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":1672238505786,"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":1672238505786,"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"}}