{"name":"@eggjs/tegg-background-task","version":"1.1.1","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@1.1.1","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"46ae4c83885b9fa15bd188566a5e2e4441da0ede","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-1.1.1.tgz","fileCount":8,"integrity":"sha512-ttYk6Q9ky4bLOJLfvETAD7nuskWG6qnAh+2CbyMFbzy51n9Z6+gQvskJ7+qFmKp4HO7JXgxwqDBPqS/sP6RWhA==","signatures":[{"sig":"MEUCIQDYDH1lNlYil5h+6T2zGD9g+7Qn1MR6pqhwUHZdJyA2rQIgdneHJ6eKp+hPAC7uvCJ5ha2cgiMpcmXUQ8uV5wcjyak=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10609,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJisZadACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpl/hAAlVZWVhYmyP1yCsW3Gn6tou/xuqsjFDRPtyv6K311GVOpBnoi\r\nHlJ3x2JM3cK+uCK81Ye59Cm64j9exbZWqw/ACbwv5qQl03Q0wus2Ctlo0QDY\r\nZpGOuDesmZoGFAQmRBQwFcmZG86rv0Uhzpr1FhJVyz8x+Y8pgQEzPi2IXUjf\r\n3slQoUkRav1ojPUXvNZF08Tk4IP4RCao1t7nw6BE2LuPSXaTMz8wpNTni6xe\r\nWRD6FOSzxAVkuSHUbhWE0jgdLjd9BhLzvp894JdNdDdm4+3bXE7jv1zeZ2zQ\r\n7D0SbCvUMLykaVjiaZc81MyQyK2Qb86EN+LYnbti6Lgw3I2PrUhPkAjjNnWC\r\nwvwhQ2Pv+YD/l7I1vlYEtbuaTIxGswU70yvmQXQxX6+as5S5s6UWmZXrq4wf\r\nC3y1gM4qOMqwIDWugTu3UUtPGBVZxnBeLozeNO8XuDwlG53Qd7P6NvjxP1gi\r\nR3DBl28xqcIhoj2NAj9TcGoXQ8h+b+Sz7730cN97ZSEN2kUdct0BRdqZycOS\r\nUiKJ8fDy+KnLT7fZmJBhbb98mCHpFxFM5IHxWvfcTnjaEydZzWKuxY6HVVOX\r\ntLgYJ5R9qsKjvtWHjnxlUAMchXMmrGRUdhN5AUi9+22AQIHjMqk2OfC8lY5z\r\nN4Yds5zf05X24AicXw02hYsLwgAadn2piu4=\r\n=3oNd\r\n-----END PGP SIGNATURE-----\r\n","size":4517,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-1.1.1.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"9d4984de5de24ac446d70fe8f5f0108afc160521","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/3.22.1/node@v16.14.2+x64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"16.14.2","dependencies":{"@eggjs/core-decorator":"^1.1.1","@eggjs/tegg-lifecycle":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^2.26.0","mz-modules":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_1.1.1_1655805597797_0.30165789990897385","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":1655805597935,"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":1655805597935,"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"}}