{"name":"@eggjs/tegg-background-task","version":"4.0.0-beta.3","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@4.0.0-beta.3","maintainers":[{"name":"gxkl","email":"gxkl203@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"},{"name":"gemwuu","email":"gemwuu@gmail.com"},{"name":"akitasummer","email":"644171127@qq.com"}],"homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"d6296f6e044f6af434665b1c27c34edcd228cf9c","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-4.0.0-beta.3.tgz","fileCount":7,"integrity":"sha512-rk3EeTaDjsV3y9PE87ifJSIXwql+akLWaGqqPYXEYnWGXUmVTIXjrTqQ2L0qJh7ftgRf3Ox+2XZdCXhLaKVvKw==","signatures":[{"sig":"MEYCIQCITPi2Pu9MChYencuud44oc7gWE5C05qKpAHOS4KQHLAIhAM9uZTHsbGs5C9ATT3lIvgwh9n/Nq+i7NSEFvqcTzM1o","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12440,"size":4816,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-4.0.0-beta.3.tgz"},"type":"module","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./src/index.d.ts","default":"./src/index.js"}},"gitHead":"6b84b0275fd728a4973746a5341236fe0481a33e","scripts":{"tsc":"npm run clean && tsc -p ./tsconfig.json","clean":"tsc -b --clean","tsc:pub":"npm run tsc","prepublishOnly":"npm run tsc"},"_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.6.2/node@v20.17.0+arm64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"20.17.0","dependencies":{"@eggjs/tegg-types":"^4.0.0-beta.3","@eggjs/tegg-runtime":"^4.0.0-beta.3","@eggjs/core-decorator":"^4.0.0-beta.3","@eggjs/tegg-lifecycle":"^4.0.0-beta.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"4","mocha":"10","ts-node":"10","typescript":"5","@types/node":"22","@eggjs/tegg-common-util":"^4.0.0-beta.3"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_4.0.0-beta.3_1742056676858_0.9976559240663738","host":"s3://npm-registry-packages-npm-production"},"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":1742056677028,"_cnpm_publish_time":1742056677028,"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"}}