{"name":"@eggjs/tegg-background-task","version":"0.1.18","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@0.1.18","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"eaf58a4617630d098d6086dcc824e5e0119a1795","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-0.1.18.tgz","fileCount":8,"integrity":"sha512-A00vfWn8eQb8xdKMXq5pBeESPPJIqJLNE5sSfK+SeQ0g2yjTCwyPAAH25zkyB8vd5xm0HxR+TchEnBNN+u3YyA==","signatures":[{"sig":"MEUCIQCdSbfAO+j341i7IUEkljpbl8Ka3DEr+avyK3hN25IyfgIgI/37h3nMS3R8MzBSPufhoZNhEalxS0Ksepl4TxCjUE0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10463,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhztFPCRA9TVsSAnZWagAAyjIP/RHTtB1tv+Q7NNggs2EJ\nnsYTif7zDFppqNysT3cXPK6tvhYPVOr3PHV98OlVaNBvRO5hTzPcOT1J5dZ3\nHGrtgdYtfXtirLkgUIABtwbI4ZUr1YH7UxdPkQ7QAIrOK4Ocm9CTfNy7qj1n\nYNdrNLLB09abSfSl5L7VzTwUa8AEFC/1VaphDJyk0GCqUNSLYiPmmPJblNGV\n/O5FxeccDCdsJs/9f0l1gz5YXTxSib6doyfhyQqCwL36y55I4HLuYNMLCq35\n+Pl+wxBG/xi1gGOd8ZLr7l8tjuNMLS5YcjjtGk238eEGSSx9v9Wy9clxB9zk\nkIdsFCnlnh+xIXr7HHxJ1VLbUYEihgP/bbWj/TVij8meG6DNNVwrsBV0vMsc\nQXpbrBSxhrKDgkNininSYfbTw9hAYkS5ffNObG4MjVDwVGQLARA4jj6Gw+eY\nT4kBSLBTTm2sgKed57KsaONsouwZ/55FZCCorGUXfPlftj6r946/xZQkJtLf\nAA1o8Kky91JeWyxZjN7pXbmJFt3MF77nl114zJreCEajPas26qQP9F0pC/4l\nmxsZ7IWQIvTkP9I/ie8spPoaOOY5T182QB4nG+geUKoi/TJebMr0VU+kBuRR\n3YunzIZHu+03ySu+ABsruld0mH7cGwVH0zP/Je0qs5Kioh4oK/rwCrWkSD6b\ntC1g\r\n=+s7a\r\n-----END PGP SIGNATURE-----\r\n","size":4457,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-0.1.18.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"a307030b00824914d23fc32dcd3fa94cadce940d","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":"wanghx","email":"whxaxes@gmail.com"},"repository":{"url":"git+ssh://git@github.com/eggjs/tegg.git","type":"git","directory":"core/background-task"},"_npmVersion":"lerna/3.22.1/node@v12.18.3+x64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"12.18.3","dependencies":{"@eggjs/core-decorator":"^0.1.18","@eggjs/tegg-lifecycle":"^0.1.13"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^2.26.0","mz-modules":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_0.1.18_1640943951406_0.14821341277113342","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":1640943951549,"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":1640943951549,"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"}}