{"name":"@eggjs/tegg-background-task","version":"0.1.2","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@0.1.2","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"d7aff6641faa5266793a8ae6b6ac35fa172efe70","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-0.1.2.tgz","fileCount":8,"integrity":"sha512-e0tNrMcYi2zG7K3QpFMSALT64zTP7c9+ETbBLxVY1Q3S5GoY7P0T+d5vx0kIEJW61JD5HtqsxH6Q+h/fuLww3w==","signatures":[{"sig":"MEQCIHHJK1B4AZBuEOTYDUUHxs+i4qKjH1FH6PziuWP4T3Q/AiAdtVwY6jFvArMvNizYsKp0w7NdetKvaZk0bfvl1CQ/uQ==","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\nwsFcBAEBCAAQBQJhLyToCRA9TVsSAnZWagAAy8MP/jOzkwI3ru+BVv8NiOfC\nCH0BE0MW2CNcNSkNDn5F6BGQULdgGuCCQ9OYLwAuEByA+mdKtbgJf9j5DIxt\nAj4r8h/x6M+V+WXH21s4yRq4m41TDvGJsWgasRT83ZHEM0ITVDRS331Bys99\nZLsGIffWjqpio4WQG4Ff918Ztp6tIzmZqI1+Cn3sGAcF7b+cuP22gZOQuB1u\nJxcD++w+pVskARx3H5rGfqy34IanAwb7pTMYv4RJ/gRsuUNoB4AsHQSUbd/5\ntMFiD7jEFp++bj1pnj8gMjqKx5pZiWeHt6mFEfGZanHUFfshW0dJN67ICD+R\n+DEdfBIp+1qqxUO6hQ+C+IbasWKznWucBhxeT7TYkANU1+Qkfidzf/jJOFyC\nTgPt19kgVPDjd7sAyKe/Jke+vyXp1YaLwW69aCv8R4w/mCgk60IqMbgr3S9p\nmWydK+en0c41F2O88tst+QZEEwJXx896Dwxp4TBrEiHRh8gJGqpB0pvE2CT/\na5JAEnkh2R+dE7X16WOiUigLCggD4I4OAdfl1u+40NPTxZDgT6M5EEwjCSYG\n6bqF/VUqRS+/ezPI4aJ2JCrSqTXTvCbhvat7Gob83TQ0efuqWaLBVH84/8Fa\nWoF1EHjBkg6Sl4kWlMklT6BObTLcnSvwzXIgrhGgnMTNyRNohDCHrpJKxeni\n2GGb\r\n=mLV6\r\n-----END PGP SIGNATURE-----\r\n","size":4426,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-0.1.2.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"1363ad169f76db7dcdd8aebac95d88d191a53c28","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.2","@eggjs/tegg-lifecycle":"^0.1.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^2.26.0","mz-modules":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_0.1.2_1630479591890_0.47500106202138115","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":1630479592050,"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":1630479592050,"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"}}