{"name":"nice-grpc-client-middleware-deadline","version":"2.0.2","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@2.0.2","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":"05b0445555ce3d5cea48d0fba0dc512106d59c5b","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-2.0.2.tgz","fileCount":7,"integrity":"sha512-FYWsDr2awI/uZQCiuLBbsLIVIIRpvVBDD5MGW3nHUeaXaOuY0nDAoeFubJEQ5nE7WtXV6kiiDDqNu5bTrJw93Q==","signatures":[{"sig":"MEQCIFARJUYkIVtWXyVpitpzhkNvlIRYpO5uNBQsm9bGQ533AiBEIrdfEn+qTrholfG6OYXGrznwf7c0vr6u85W9sbhlOA==","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\nwsFzBAEBCAAGBQJjx4hOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpQtA//U6kYNWw+HyC3E4GC53FN5QJUs9CUK8R7Ui9ZcmH1tZW026GF\r\nacKC3ufVK9SNBlQqfs9OV+0oTjg61KHbk0nKvK+iLuwAo2+4DFCWnoZcV4vh\r\nXZmmvDpLuFbff6C6AQ06LzGysz7HdzXVfx0yVLEvcC5nqUcjaLbO7ADsf/y5\r\nUrePQW2OoyqYOnj9TiG4gjbmU9A/MFjEgdZBvGF5wmOS6uZKfDkWUbGrQ4Yt\r\nuI0Omz3GANxI/2U5+Uksyo2DUL4t/f+ayzL63U23lop5Rsu4opP/6OcTapnT\r\n3rS9T96zsFqEADhXWh4pbtF+jNuLBYPvZoEAVgdtq9rMcFIy/VANDgL9sxGf\r\nWc+GUSFgH6sQsRhrq1pqB6YqL0tMEXEHZ3j2gLcj9spn6loJ/v30YPelZ+b2\r\nNIQJkBzuVBIPfGk0nz/Y6CYbA6Khsg1TGos0mrK+83FUsg7MENFVB8b2RizV\r\na0eUusnjRyNyHyLpc/z0fZI+d3WIjtRY9nEXqYBaPyCssHwRKtTiByJHluF3\r\nnnOhHQyVujQkQQwgwzlxs8FEmOj2WFEwtCdrspwQcKXEw788/eQ10RY0y1Ai\r\nEbT4MeCePsOL2xWXBVAQaMgAp1H+0Sn2SwE6CeebKREYmBPhrCnBhlBthvSd\r\n2ZFlyYga+1/lL4RxYoMSKjKjR6ctRZhBcXE=\r\n=pg1S\r\n-----END PGP SIGNATURE-----\r\n","size":3259,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-2.0.2.tgz"},"main":"lib/index.js","gitHead":"090b1090ea4ac6859d7f240386fdac48415c1969","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.3.0/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.0","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.2_1674020942511_0.2139684711004488","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":1674020942670,"_cnpm_publish_time":1674020942670,"dist-tags":{"latest":"2.0.21"}}