{"name":"nice-grpc-client-middleware-deadline","version":"1.0.8","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@1.0.8","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":"40784e123a5690189f1de4d65432be78af97bb5f","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-1.0.8.tgz","fileCount":7,"integrity":"sha512-1YCapjq6Uo8bc0s02rrF4RCWZ2L7K/bUmwksU1W7Ew6SvqmaU2WejhJY+ubHRcD651enfjVoePhNWBnqMNrJuA==","signatures":[{"sig":"MEUCIQDGUCRC0ffSqnvdoemhF8+t9oudqdkUau9fyRJaNdBWSAIgIT6m8aBF7+S2Wu4SYylkybcbffxHOz7pHjyOin2JsDg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7917,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKCkzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqmVQ//Vd/8bTET0Syl0RIHbykipEh/pEsztB0T8dMPNjo17ujfwNI6\r\nH3VwJtgZCSnEoPL3fatctxKQq4k6ncUQFtItPnc1V0P2OMwxdv4b2NIUhYRy\r\n1RP5bhuInaK2EJf4fQZnSKQzt5OWB5528OX8UVCXTenXRfQMSmADIycX+O9B\r\nsixmzmmU7rfmx8G9AfbeMco5vZ0IJ4bSZ2cGZILuRtIIBJkWsTtllSNOHpZc\r\niRgiAXDMJD8vSTGMNYXRTpy1LnWV8Q2REy74H7BkDiWcaFb3GZUQC4TL0Vv3\r\nTTHJ+N4wOpwnU7mPxA9hTb6FYZ+XDvqgl1VWd8N54opGgltD8SlaXx3Xj6/o\r\n4Pcq/GxBlVpUmtsmwxwc05rwjDT8KLuITNWedAvmZkocmnghG32HRvKzKy1T\r\nrkpGSE9VSur9xraTYaPwwsy/yho2EOPI8Dng8at2j2I1ySrFE7nFkbKUTsqA\r\nodIdOP+In4Cw6QwB0LtDctcOVbWrflYHh65bSp5IEjVbFRHHGsRNZJpKPIsl\r\nqTiHHpVw8FsBRb1uN58+n0Do4M430qGeL+K5kCmugIrkNdusH9tb0ddCQ3N/\r\nzX9HfnNmRBG8l3O/6VQ7swQeLCxji/PwGXZiryR+2Ju6zCoOFentJzGyDp8y\r\n88pOjqwzNvTsyRN1nwY7hJtUprfTj8RV9PM=\r\n=cPmb\r\n-----END PGP SIGNATURE-----\r\n","size":3258,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-1.0.8.tgz"},"main":"lib/index.js","gitHead":"3c1c4e803cd73e6b5feddf50d64710256d1a12db","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.13.0+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"16.13.0","dependencies":{"nice-grpc-common":"^1.0.6","node-abort-controller":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^1.0.8","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.0.8_1646799155788_0.027966615383520077","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":1646799155930,"_cnpm_publish_time":1646799155930,"dist-tags":{"latest":"2.0.21"}}