{"name":"@eggjs/tegg-background-task","version":"4.0.0-beta.11","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@4.0.0-beta.11","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":"akitasummer@outlook.com"}],"homepage":"https://github.com/eggjs/tegg/tree/next/core/background-task","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"51df73569285cdb0076d9b1c3964ec68f040e8ce","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-4.0.0-beta.11.tgz","fileCount":7,"integrity":"sha512-dtATtPZQ2MMwdwdmluAPxylNKu48+JyvLVQta9UdAQQsDwJ3A4e1Jftpuh/FzXSFTSTYNcjkE8+v/DXEFM7FDA==","signatures":[{"sig":"MEQCIHI5p7F2ldVzy7+scwP6/8wyqqo2s0BRESHITdDV1wMNAiBnTBMhyfSm2D0SwFUHsf95IePaJ9yo02t4JCXjJp5nxg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2ftegg-background-task@4.0.0-beta.11","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":13232,"size":5000,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-4.0.0-beta.11.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-tegg-background-task-4.0.0-beta.11.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"scripts":{"build":"tsdown && npm run clean && tsc -p tsconfig.build.json","clean":"rimraf dist *.tsbuildinfo","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4f05fa15-1b84-40c3-a663-0da0dcd13fd6"}},"_resolved":"/tmp/9048a91eb8edfe57368bde5ac0600971/eggjs-tegg-background-task-4.0.0-beta.11.tgz","_integrity":"sha512-dtATtPZQ2MMwdwdmluAPxylNKu48+JyvLVQta9UdAQQsDwJ3A4e1Jftpuh/FzXSFTSTYNcjkE8+v/DXEFM7FDA==","repository":{"url":"git+ssh://git@github.com/eggjs/tegg.git","type":"git","directory":"core/background-task"},"_npmVersion":"11.6.1","description":"background util for tegg","directories":{},"_nodeVersion":"22.20.0","dependencies":{"@eggjs/tegg-types":"4.0.0-beta.11","@eggjs/tegg-runtime":"4.0.0-beta.11","@eggjs/core-decorator":"4.0.0-beta.11"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsdown":"^0.15.6","typescript":"^5.9.3","@types/node":"^22.10.5","unplugin-unused":"^0.5.3","@eggjs/tegg-common-util":"4.0.0-beta.11"},"peerDependencies":{"egg":"beta"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_4.0.0-beta.11_1759689074042_0.38413710554904523","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":1759689074232,"_cnpm_publish_time":1759689074232,"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"}}