{"name":"@eggjs/tegg-background-task","version":"3.4.1","keywords":["egg","typescript","background","async","tegg"],"author":{"name":"killagu","email":"killa123@126.com"},"license":"MIT","_id":"@eggjs/tegg-background-task@3.4.1","homepage":"https://github.com/eggjs/tegg","bugs":{"url":"https://github.com/eggjs/tegg/issues"},"dist":{"shasum":"fbd19e780c4c14b3e479c8fc0626f2850c195481","tarball":"http://registry-npm.ywwl.com/@eggjs/tegg-background-task/download/@eggjs/tegg-background-task-3.4.1.tgz","fileCount":7,"integrity":"sha512-wQetVLtm7srVTT4SLL9Ab6JpGBaKwEyp/u36aSsLb/CHEiEm/g/h0SdudfrMZ0vz0qQr4Byy0twe69gl5Yjrpw==","signatures":[{"sig":"MEYCIQCTmrO2LSTWa2K6LYzhxFllgI6qbSU07ZAO+wKspwmMCAIhAPx4JuSQPSBGI1tS/da/ZJzFj/qJHqONhS4tK6ccJF/W","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12540,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj21hoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpMbBAAnlBuywYKP1sjYQJ4IaIa4nwB7vEI2kpvVHKqtL/A2avYYFwP\r\n5Xxh2NNwES78RuXWDNuQpQKZBc6hZSVK4YTNJil0qa9IC5h/vouFQ/Nomt6A\r\nX5rkGEHjGK2gIrL9e7RUMiPeusc7IOZ4mh4/Xc9B1U3XikEEsH7jRmNYqe14\r\nfFDvRs8tgIVE8hxTeTn2iEyBIUzwVPtTli+SP+pIcIzYAZP4LOajiulLUXbI\r\nTiDJhl5q34HS9bUKM9V1Em2ogOpfnPRx8rt1RxWZVK4dxhNd1cE+zno4H8wZ\r\nd7nNUldAN96iaBO0iT6bysPCNlmBeSW6YQTIl0zQTxf+jhZWz4mBjvBtPa67\r\nY7YWflloLvEUisDj62+WtRDffPGL6jFcVQU7iFev8L/3vv+1HAstsJcG/Vr8\r\nulCiloDk6c4BxqGtpmBWWOJyyMiYTz9WTsvrGANNaRs1Bw+giyt/OM0cLxfE\r\nmDjMCiWwlDl73QEnZDaXZ1p0Kot6mvyrj6GCsCIBYsv9YTR/4YEXiWONgXXz\r\naKsgnBAoto+6OAC5Ha+Kq+5xgH2gc7GQI7E/D9lvQ2bNrE+QBVKbhOZ0K6jV\r\nul4s5xLdKlCFC6wx3XuTR2/MGdENNV67KY3y/2fxRhrH+6/aMT79G3X6gzC7\r\naVkO9nlwitkpAfizorEJkVzT2UurWJaAQB4=\r\n=LEhK\r\n-----END PGP SIGNATURE-----\r\n","size":4973,"noattachment":false,"key":"/@eggjs/tegg-background-task/-/@eggjs/tegg-background-task-3.4.1.tgz"},"main":"dist/index.js","engines":{"node":">=14.0.0"},"gitHead":"53c6f0685df3c7fefbbc2f3af1a83f8b56bb0a9d","scripts":{"tsc":"npm run clean && tsc -p ./tsconfig.json","test":"cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha","clean":"tsc -b --clean","tsc:pub":"npm run clean && tsc -p ./tsconfig.pub.json","prepublishOnly":"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/6.4.1/node@v16.18.1+x64 (darwin)","description":"background util for tegg","directories":{},"_nodeVersion":"16.18.1","dependencies":{"@eggjs/tegg-runtime":"^3.3.1","@eggjs/core-decorator":"^3.2.3","@eggjs/tegg-lifecycle":"^3.2.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"egg":"^3.9.1","mocha":"^10.2.0","ts-node":"^10.9.1","cross-env":"^7.0.3","mz-modules":"^2.1.0","typescript":"^4.9.4","@types/node":"^18.11.18","@types/mocha":"^10.0.1"},"_npmOperationalInternal":{"tmp":"tmp/tegg-background-task_3.4.1_1675319399844_0.6148096454619092","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":1675319400000,"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":1675319400000,"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"}}