{"name":"nice-grpc-client-middleware-deadline","version":"1.1.0","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@1.1.0","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":"ac4a6258557b773c30bbafdaaccd4b33725e7244","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-1.1.0.tgz","fileCount":7,"integrity":"sha512-KIWNiNpswcJQL8dbVqHyFYqkk+e4Q96ADrxvDCy7RWfb2EAxXhq/nD2L2KcgG7fCrpSxJPLMv2d3sE9lSNJi9w==","signatures":[{"sig":"MEUCIGwIhhk0XxeujSeGmhenXSjz5qWJSwtHDXFq0WVvE0CwAiEAhhvHj2QFTkH/pUpcWNxMhYDqphQqb27kkBGzK4Eblf4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8343,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJidJ6yACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrB5RAAlL9B3DLLVYuOG+gE/n5wE0Fx7mSzIozwNXBnMctzZ6+Nv1hi\r\nFFFSU+c6IhhLKuTxHmX3Rnp/8u8fIWOEmV9+pXI/eDQmoyn3KHCnwZjv52SZ\r\nPU0npt1FriPQXMOyMTQS8Y1ilm1KWVEbBzgZrsSIlJhkMABP2wK/tsCqd4OG\r\nammKbcG8/Fq1i0nDwkzaAJmO2EIiZuZOq91hjtlThoxM11wFd8GYvw6Xb60+\r\n04M4nzY3WJbUnzCgyO+HNcIrRd2tLwvkp9Q/E3o74tVw21/SxFP/sPkUZeT9\r\neKmSVmszmd8NDSu2K1LzHxMOnxY2k6EWQCR4NGakg9MO7bS+hQ2N/HlQQvZw\r\n/YMFyafq7wYUP1/x8LZUusjil2Lrlb3+rK6vmulJMQ/hwa9eoGYHKlzRjtbt\r\n444F2KN8RugMYY3U55C+XuldSCf8FFhiOowkzGexKwQsEGSemhONviS4eevi\r\nUinczYV1XDV8GeX3Mcw1DkokhVwNh4Hu3fAZqklG43CCKcJqyBGNjoctsc3I\r\nFvD3v68h6x32tuPb0dAFSUMA48WxEr0Fg6kV5q40CTrseb9LneJpKDtwXFrO\r\nYWCDl+rMlj+ZAekgxpKiAQT0bcG8b/3m9wBsLskofXfRnybahLpzE9hhvnHF\r\nCg1N9l9eQL73D+2O84Zb59sLLfj+cEthRL0=\r\n=x0DY\r\n-----END PGP SIGNATURE-----\r\n","size":3384,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-1.1.0.tgz"},"main":"lib/index.js","gitHead":"1c588bc768b834bf84178461ea5a796701fa89b1","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/4.0.0/node@v16.14.2+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"16.14.2","dependencies":{"nice-grpc-common":"^1.1.0","node-abort-controller":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^1.2.0","grpc-tools":"^1.10.0","google-protobuf":"^3.14.0","abort-controller-x":"^0.2.6","@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_1.1.0_1651809970136_0.82374415644791","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":1651809970330,"_cnpm_publish_time":1651809970330,"dist-tags":{"latest":"2.0.21"}}