{"name":"@eggjs/tegg-background-task","description":"background util for tegg","version":"3.88.1","keywords":["egg","typescript","background","async","tegg"],"main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"test":"cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha","clean":"tsc -b --clean","tsc":"ut run clean && tsc -p ./tsconfig.json","tsc:pub":"ut run clean && tsc -p ./tsconfig.pub.json","prepublishOnly":"ut tsc:pub"},"homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"repository":{"type":"git","url":"git+ssh://git@github.com/eggjs/tegg.git","directory":"core/background-task"},"engines":{"node":">=14.0.0"},"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","dependencies":{"@eggjs/core-decorator":"^3.88.1","@eggjs/tegg-lifecycle":"^3.88.1","@eggjs/tegg-runtime":"^3.88.1","@eggjs/tegg-types":"^3.88.1"},"devDependencies":{"@eggjs/tegg-common-util":"^3.88.1","@types/mocha":"^10.0.1","@types/node":"^20.2.4","cross-env":"^7.0.3","egg":"^3.9.1","mocha":"^10.2.0","ts-node":"^10.9.1","typescript":"^5.0.4"},"publishConfig":{"access":"public"},"gitHead":"c21401cd56b74b8a6692d5709dfe15d8fca57b48","_id":"@eggjs/tegg-background-task@3.88.1","_nodeVersion":"20.20.2","_npmVersion":"lerna/6.6.2/node@v20.20.2+x64 (linux)","dist":{"integrity":"sha512-amcez3H5xZSyhFv0BIJDHGeQkEhXsjutg0msxjITviUS0aPySADDTKpJD3PXP3svwlbu4rkbrE2Lxta0D1MEnA==","shasum":"527e5381526aa9b44f0c3e3d2674f073c5729654","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-3.88.1.tgz","fileCount":7,"unpackedSize":13727,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC2d/FL/s/9PQfZgFC7/MVedTvmT91C8xBkbH/FVjjgUgIhANBwyBEiuN9A5oGXINRCq3Z+i6MXYwAisCkHNQ+D5AWq"}],"size":5273,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-3.88.1.tgz"},"_npmUser":{"name":"akitasummer","email":"644171127@qq.com"},"directories":{},"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":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"akitasummer","email":"644171127@qq.com"},{"name":"elrrrrrrr","email":"elrrrrrrr@gmail.com"},{"name":"niania","email":"ljracm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tegg-background-task_3.88.1_1788854390833_0.27044469465459"},"_hasShrinkwrap":false,"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":1788854390952,"_cnpm_publish_time":1788854390952,"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"}}