{"name":"@eggjs/tegg-background-task","version":"3.78.10","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@3.78.10","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":"niania","email":"ljracm@gmail.com"}],"homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"67337d98b96ac280a17ee0e28af0517c36b17629","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-3.78.10.tgz","fileCount":7,"integrity":"sha512-vNYfEEardJOE+5jwjE4OnVAHq2BvmIOAdCessLU9JNWyI6c+mpzhwB7NL9QS5mj0bEWfAghgi2LAqtn2nhbDig==","signatures":[{"sig":"MEQCIGS7e2aujpRLdP9gFlqWniR4fq0AvsnaESKE33Zk2xKjAiAqrFKjztIrFbtyisF8tXJ+LdyROMeUUzwHAgIiTqyqyg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13733,"size":5275,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-3.78.10.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"8a61a3e5e663054a62970caab0e71076e3df1120","scripts":{"tsc":"ut run clean && tsc -p ./tsconfig.json","test":"cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha","clean":"tsc -b --clean","tsc:pub":"ut run clean && tsc -p ./tsconfig.pub.json","prepublishOnly":"ut tsc:pub"},"typings":"dist/index.d.ts","_npmUser":{"name":"niania","email":"ljracm@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.20.2+x64 (linux)","description":"background util for tegg","directories":{},"_nodeVersion":"20.20.2","dependencies":{"@eggjs/tegg-types":"^3.78.10","@eggjs/tegg-runtime":"^3.78.10","@eggjs/core-decorator":"^3.78.10","@eggjs/tegg-lifecycle":"^3.78.10"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^3.9.1","mocha":"^10.2.0","ts-node":"^10.9.1","cross-env":"^7.0.3","typescript":"^5.0.4","@types/node":"^20.2.4","@types/mocha":"^10.0.1","@eggjs/tegg-common-util":"^3.78.10"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_3.78.10_1776522123039_0.6249120170117031","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":1776522123245,"_cnpm_publish_time":1776522123245,"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"}}