{"name":"nice-grpc-client-middleware-deadline","version":"2.0.6","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@2.0.6","maintainers":[{"name":"aikoven","email":"dan.lytkin@gmail.com"}],"homepage":"https://github.com/deeplay-io/nice-grpc#readme","bugs":{"url":"https://github.com/deeplay-io/nice-grpc/issues"},"dist":{"shasum":"a9f3123349f85f85241a3539d9615b8d7c4d4de6","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-2.0.6.tgz","fileCount":7,"integrity":"sha512-bbatthC3ElTyDgyig0w7FKhAMeuKvLiNO0W9ehxGgTqGV3KQnyUvTQvvOifu5PQ3pFbB/my9Fq0p9L7VDJRBBA==","signatures":[{"sig":"MEUCIBlRDpF3QoS48bzpXh5iZTYPGAIMZHqZeD9l/I/8kFxqAiEA3x6KfR3ZcuRnodAR1aR43TgRQq5aLWDbAC7OcJ5iMR8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9049,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkJ1CiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoQAA//TXfKYVzzv+VARVrTQZMGgsBb5zswfgo7DzAuJlmZOk27sJq/\r\ngiO7BCSb5EJPvBEb6MCfnn/BRYpBWRqICAyoauSI5UoYf1c5aRxnkQMJyn7a\r\ne9d0ib8pKT7U/RbSLLiRcKXOQOGsjJub1VXODw0ibozST9s7MT8tM62MU90F\r\nDn5sUxiSOq+ruP2Q1Zu0KSmSM7dX3i2VxxJgzCdx8GYmu8x7StzlkyLJL0Yf\r\nANmEbU+i5fIN4sInPVDS+JER0HkCivnm8z2MBlMgUgZcFafXgQU2h08jmcBt\r\nHmfla8y/hNb6OreioZO8V/OLGJ8bRdpjbaIaNbcsvWhztT07mV0NppqW7udD\r\nCQenL0Wxbi+mk1F/s2zLITEFkUjr8d22esws/fr/+s/XDcCv71+4KEjgvmuX\r\nWxqndykOCZbyM+vfr7esirRxiEz9j/A429jdrq6TdzPbqt5qgDzSen5s6ZvG\r\nTtG5Jo3w7vGdgbZV8znwWjhOBpNTYPsOvxuUpdUgThit24OKilY1HXBOzFXY\r\nfJfuW3rVCMmNDkCd4AEtUQL7dBXS8dq6Lsky/BvOfK0KRWtXkAl8I0jsdMDP\r\nPf4MPuq5ooOpNIEyG1vH5FggXRBWZor8iU/vi3YMtaKeJQPNf4yUHIA+NLXi\r\n0nDuajuMqy7UpLkaXn9V+CQTIqinvhIidVg=\r\n=KgEj\r\n-----END PGP SIGNATURE-----\r\n","size":3430,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-2.0.6.tgz"},"main":"lib/index.js","gitHead":"a2987f236be78513ea607faf691c9471d640bd0e","scripts":{"test":"jest","build":"tsc -P tsconfig.build.json","clean":"rimraf lib","prepare":"npm run build:proto","build:proto":"grpc_tools_node_protoc --plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --js_out=import_style=commonjs,binary:./fixtures --ts_out=grpc_js:./fixtures --grpc_out=grpc_js:./fixtures -I fixtures fixtures/*.proto","prepublishOnly":"npm run clean && npm run build && npm test"},"typings":"lib/index.d.ts","_npmUser":{"name":"aikoven","email":"dan.lytkin@gmail.com"},"repository":{"url":"git+https://github.com/deeplay-io/nice-grpc.git","type":"git"},"_npmVersion":"lerna/6.5.1/node@v18.15.0+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"18.15.0","dependencies":{"nice-grpc-common":"^2.0.2"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^2.1.4","grpc-tools":"^1.10.0","google-protobuf":"^3.14.0","abort-controller-x":"^0.4.0","@tsconfig/recommended":"^1.0.1","@types/google-protobuf":"^3.7.4","grpc_tools_node_protoc_ts":"^5.0.1"},"_npmOperationalInternal":{"tmp":"tmp/nice-grpc-client-middleware-deadline_2.0.6_1680298146060_0.7155734929715032","host":"s3://npm-registry-packages"},"readme":"# nice-grpc-client-middleware-deadline [![npm version][npm-image]][npm-url]\n\nClient middleware for [nice-grpc](https://github.com/deeplay-io/nice-grpc) that\nadds support for setting deadline for a call, after which the call will get\ncancelled, and a `ClientError` with status code `DEADLINE_EXCEEDED` will be\nthrown.\n\n## Installation\n\n```\nnpm install nice-grpc-client-middleware-deadline\n```\n\n## Usage\n\n```ts\nimport {\n  createClientFactory,\n  createChannel,\n  ClientError,\n  Status,\n} from 'nice-grpc';\nimport {deadlineMiddleware} from 'nice-grpc-client-middleware-deadline';\nimport {addSeconds} from 'date-fns';\n\nconst clientFactory = createClientFactory().use(deadlineMiddleware);\n\nconst channel = createChannel(address);\nconst client = clientFactory.create(ExampleService, channel);\n\ntry {\n  const response = await client.exampleMethod(request, {\n    deadline: addSeconds(new Date(), 15),\n  });\n} catch (error: unknown) {\n  if (error instanceof ClientError && error.code === Status.DEADLINE_EXCEEDED) {\n    // timed out\n  } else {\n    throw error;\n  }\n}\n```\n\nAlternatively, you can specify deadline as a relative offset in milliseconds:\n\n```ts\nimport ms from 'ms';\n\nconst response = await client.exampleMethod(request, {\n  deadline: ms('15s'),\n});\n```\n\n[npm-image]: https://badge.fury.io/js/nice-grpc-client-middleware-deadline.svg\n[npm-url]: https://badge.fury.io/js/nice-grpc-client-middleware-deadline\n","publish_time":1680298146214,"_cnpm_publish_time":1680298146214,"dist-tags":{"latest":"2.0.21"}}