{"name":"nice-grpc-client-middleware-deadline","version":"2.0.1","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@2.0.1","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":"e11716a0d473cd09bb95a68109a110cb12a30b9d","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-2.0.1.tgz","fileCount":7,"integrity":"sha512-jEyFjkqfctoE328+P+HmStfGr0PLpc7QMeN8nchIf5AzPx2S4zyz00Err5VWWG9p7ASzFcaa5DrnoGp74BZhvw==","signatures":[{"sig":"MEYCIQDvn+gAqjWbLdY5I3UyIgy9od0VZEJmVUNxojnCHMi3XQIhANXGVycKLn+CRthxodR9iudX2HTyKxV1BvBXxeJDcpZ1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7992,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYmYvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrKmw//ScyVj1I1FP+5UCOynqfqRdO4O6AeUnBz5yAkzcb1fOJWKc1D\r\n3cuiwWV+F9N7FCkAcbUtCviMrwHV24ibHOK8DN5qmjpPdXuRUU2DsUEo4lXd\r\naWxcQ9m9nC9ZQRFJX6YXDIDIZaHdH8rqejmq4/0EvX/jdN0+K7EB5PlxNbO3\r\nHWda4Skqq5EheW0hp9L5cjqQBKcIYFj3l3HTHo2KQ+1SJvwE0nkGLS0uo2u4\r\n29S1z6gpwxdxSPXSzBbZhUSCohexN30QnhuUX5W1cKqFQm4ErbXQ8L3vcn8v\r\n1768kQQvYk4edmemCiFKx1Ekt7vg2qTwcBY8TlzSy9ibyYzgG2j4cgbB1DxN\r\nGne2ovETTKFtnQCw+aG2kx4gIa0sq69vIuLjkYWc55SvdQOIce7Oe7VTUGlT\r\nxJlE6PItWfH5jJyvNGeSfuwqJAGqvp/X82xtEGA2mxu4iaEhh2D7GVmQOYcx\r\nrZTXCWAvYtyS2pWTmcCcfXFL5Hzzk9geBeBfcx4yf+wkcVX/C1HYLwjAx1Bf\r\n8dAn3Z2M6vCLSd5PsbCXi2OR2NUGsPVpRf7w2v3degybr64z5cpHBOH7xldg\r\nD12bk+lx/lX0lJC2Om4825gPQHfuQ+x+JYEGS4LKarO8ZSa8heWuOYJRNqyV\r\nz4TA6RVW+00CqAjJLQr+VYfq2139TpVOBSI=\r\n=E0Rc\r\n-----END PGP SIGNATURE-----\r\n","size":3255,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-2.0.1.tgz"},"main":"lib/index.js","gitHead":"b0afa3e8c3c1c471f9b1307b122cc434da2c2151","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.0.1/node@v16.14.2+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"16.14.2","dependencies":{"nice-grpc-common":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^2.0.1","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.1_1667393070984_0.31365909193261365","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":1667393071128,"_cnpm_publish_time":1667393071128,"dist-tags":{"latest":"2.0.21"}}