{"name":"nice-grpc-client-middleware-deadline","version":"2.0.3","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@2.0.3","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":"a20ba776fa801f8034371bc0a2368da31b0b1db0","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-2.0.3.tgz","fileCount":7,"integrity":"sha512-PrqEvCpVM3cl0rPjIQBwUMwUwGixQXpAdq8V4gJN4XxrJm30SYNj8CxNiqJyVirB2WGbUNbaizm8pq5neo+/pA==","signatures":[{"sig":"MEQCICVlwbkHpmZW7ejYg4Vu7CzGdQoum8wstZP9Gw3VWNxUAiANt3CBi1i1NwCclXc2Z8s0cUw2YvRU1k4Kj5svnqcqnQ==","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\nwsFzBAEBCAAGBQJkBQiJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp14Q/5AMAm9axJwHpqi7fG9phtqZXs6Y/FCm9Z1aHU7A3IGiH6pBHH\r\nj98ZIXiP9ktoQqLnUvKPUfMXxhsd/4JCMD8cOEx3v6y3tupvhpqZyVaQZHbO\r\noha9dIxL+D92tdiscKquZLDm/11KEG8s7+QE45r9JaRhAu61T+UEdTrPFUsx\r\nuSe3b5ssj8DUYIeJw3ram4rKe8wWYKabfP46jdI/w9J300oq3ukCEzJhChf2\r\nOMNPpU85HLLXrXM6L5loLYZRcYW+Xx0oOo9jkcAAKtI1/dgCnM+0hEtppUEV\r\nEhqQrh+M1ZIS2SBhv4YtYcnBe1cG3DhrspLnWyi6MLAMYQlHORwaXuN8Z7d/\r\nGEkvGD/v+3lYAj3UwfNp/5igjpSSet8E7Z73HbvobMJ0C5q26KfOfxUhigZ4\r\nz1DWikltonUU3yPHHpAFzuqlZoTXcTHXFZ8at5DJBJfji32yhdhXVXZhWwia\r\n5isa5NGSZj+42dS+UCXSaKepMEIUxWp3Jtqq1jnKpeW87zdKXkm/kZVMInU9\r\nIuGHKZybfu333RKaAeKqqYiwZrtwjYlcN9/gUICFma/4l3LCwv226XZ/uIox\r\nrplpKhnSoG46JDSstIJ7d70MG3N1yhjJZZfc2Ln+swieXbkN1Gy1VS7pw+4C\r\nTh+nSWeP5ptwA1nn6uQC8rckt00CTzGNp8Q=\r\n=rwR0\r\n-----END PGP SIGNATURE-----\r\n","size":3259,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-2.0.3.tgz"},"main":"lib/index.js","gitHead":"32f276646579d3fdb7ae18fc72bb17c1b86b5ef3","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.12.1+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"18.12.1","dependencies":{"nice-grpc-common":"^2.0.1"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^2.1.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.3_1678051465352_0.35831466814080204","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":1678051465538,"_cnpm_publish_time":1678051465538,"dist-tags":{"latest":"2.0.21"}}