{"name":"@eggjs/tegg-background-task","version":"0.1.6","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@0.1.6","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"25f94fc34f0cfc0c102d136654e5b3be02c45753","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-0.1.6.tgz","fileCount":8,"integrity":"sha512-Th9n3nR5RRAD6PrAGPBKDV47HUvfI3y9yi3eEpJmYUBi8hNAMyS6KVc2GJFE9N1c8NPEs2Y7YpwlQq/UvYHAIg==","signatures":[{"sig":"MEYCIQCw/6gaYe4+686P+F1CKN8ft7sLXQZ2b1+ObNJY6dzzJAIhANsa6sCVm5oycisIf+iN7FX4qRQXXJcwmoP/jYzNdIHI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10411,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhOgBFCRA9TVsSAnZWagAA8TMP/jYErEaaQEYgEa5FxFm5\n/BUk9bG1X/CJ2JeXxxLE5oDUy2iI93dopUe5QDFcD/+ax/qoaIfF2oxDE1rT\nafmDFodhO61Ufyb0C8BdbXA9/JNMM6kODAM1X6lhpZ7+tC227hR7QpmkALnd\nd0wPQrT45ieJWAyg1tbhXGGCQy7J9E7RaM41S7IPzMdscea/MmEeQ9gkHOVB\ne7vn/o79+b9eFcRO3xhiwiRR/5Y0iCfUnurg7ZBn4PblXVagHOVVCL+z2mof\nGdf5gTa/WGYsbJ8jFn7hZ19LC9fqFcH18QzRH6WVCvmmEr1DpaMnVxlti49J\n5zQjpCeU8cwkQ3tQhAraKIEuSZ1aJybN5FvnfHISfdVUnNUdU4WzsPApdL4y\nOinszfr/K6LqoXMVJ0KnfbRd7FgXTOBRiyScp47T+W8FHzWTo5gH+BDK1121\nZGw8VuNN7URjZZRJqqmmFDgth7/C8votFw4bQATkxFLHWLUjKys+Rk7pv8TF\nyOdbM+/X0J0ethIfb9063OcQzIo3iEg3SZousTPdtXk8wd3TEMfLExo6VsMa\n1HCsi1/3l5MdbyErGAXSBBUkNz0qYIgYEOBdRlwXjeqeyXZkCGJXMMcZYc6b\natg9sm8iPKfRzlVYy73Ynxl7UYldFz5ZSmRZ3xU+x/Xi3khM9NYINZFs7rRl\nx5dE\r\n=/Csg\r\n-----END PGP SIGNATURE-----\r\n","size":4429,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-0.1.6.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"580a06e883c5f184481ca8ae030ef34d405660e4","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","prepublish":"npm run tsc:pub"},"typings":"dist/index.d.ts","_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/3.22.1/node@v14.17.4+x64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"14.17.4","dependencies":{"@eggjs/core-decorator":"^0.1.5","@eggjs/tegg-lifecycle":"^0.1.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^2.26.0","mz-modules":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_0.1.6_1631191109647_0.7349995142680839","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":1631191109762,"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":1631191109762,"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"}}