{"name":"nice-grpc-client-middleware-deadline","version":"2.0.4","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@2.0.4","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":"55e56586ed874e5e7275b9820053138887fcab26","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-2.0.4.tgz","fileCount":7,"integrity":"sha512-MgBUO6xVDPQmNc0Bammag40bQnmcQ0VEyAanzuBuuTHxLHTxPPsK/HlJ8CjHHnQ2nKNSWUyU28p9TT1Y0553uQ==","signatures":[{"sig":"MEUCIQDcG+NNbeSPHa69SLdTpfBIsQUQ5YWqgMtllSmaJG+rCgIgWvy1ZNxPniShISsk9TfLoWQGpBAL2aut6Oagw//DYnY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7984,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkDEtqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq5ug//VfhO+iMzYUHkrSvIHuBG2qcE9CXA0bBzslFGNDwAJd3v9uYt\r\naE01sS/ydZYiHVWidSXNuqLZZnRNsaKK9N9OIDoDwc1JDPewnIUMW8qHtI9J\r\nB6ph5EfDZ4s2Unc78K/s8MjOwm+z3QYSqMztvLAliF4F16MTl1y/yyZ5BU2w\r\nLXaZtmyvpKvMW8pdnHVROncNfl5tZFx0mR7YkrYfqZ8bPhGahbi9wgwhRdvt\r\nQsuG1Fc5cO0KIQatrZ6zxovdBpkM0vuJgqQj6dBJDmXnrPlk54VYOxk4iWJj\r\nfDFNMSarumJFTa2p6JaAvxdDtPPSWU0rTSX4KkRUlRTJ3FqeW2OwyO+NIokf\r\nUpnFtTOpXGe3GR5OKYbYMI4WcVJn7OefggDVkfm1wLVa8+F3zLfaHgg7a58F\r\nJx2PZjNGHpu4D8YentybG4CCLLxKo5RhezkJNT1GmhKX65Dv+uVzOgAMBwwg\r\ndJD8gLvAOtiiVlJgXqSZFtdSfRNijwQue8n1PS97a5ZKQnvaOMexSy+vadNe\r\nqBwycJ1FaIMqe7WVRbDL0C085QpTs+YP6QzX8d023FMhKdDyKa/7IXPa6DFx\r\nR6eI2uLPDvcH+UDEJBfY3b6l1YwNVJPUFyJUQIgulmhcK7fTiZUXru86sGjn\r\nQ4k1J4Wc8YAnWkewIyDYhQ5GHhffC5/SZ28=\r\n=tV37\r\n-----END PGP SIGNATURE-----\r\n","size":3263,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-2.0.4.tgz"},"main":"lib/index.js","gitHead":"b7da78d63a8d75858755778197fa90ae43900fd7","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@v16.19.1+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"16.19.1","dependencies":{"nice-grpc-common":"^2.0.1"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^2.1.2","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.4_1678527338573_0.8938225824349133","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":1678527338744,"_cnpm_publish_time":1678527338744,"dist-tags":{"latest":"2.0.21"}}