{"name":"nice-grpc-client-middleware-deadline","version":"1.1.2","author":{"name":"Daniel Lytkin","email":"aikoven@deeplay.io"},"license":"MIT","_id":"nice-grpc-client-middleware-deadline@1.1.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":"195b62c4ffbae0fdc6f943632c8d13528a61fee8","tarball":"http://registry-npm.ywwl.com/nice-grpc-client-middleware-deadline/download/nice-grpc-client-middleware-deadline-1.1.2.tgz","fileCount":7,"integrity":"sha512-kZbjCU/lF3kMtuzriKBREYIehIeRLG0uW0nuXBKEBHTY04rT8Jzj77GXJPOj+eotxlXUJnvm2FlpoHhcJu9KZQ==","signatures":[{"sig":"MEUCIBIgGycdrGhhjb4pcwDFA9+ImvA4L132Kojdknh2FN19AiEAyWMuBlzLydQger630XFpUDI94urO0l/bTkBAGaGpuAc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8343,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi503/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqkfg/5AUggn9/kMbFvEeXCnT1Nc4n0/MZo5KtFTkN4nVYnWZMZDHD8\r\nnlY0+rHgmHWlb2+EWWckC65Mxk4LqiqiTRfQphh6PIHzXe+BpCDyWQFK68iI\r\nahn//qd+DX6a65nDbNVAZRbpgNrvvNr84kdd4cCgCw0TMo4ToWuTu8sraZ/6\r\nskw9n8oB1G/BJST/o6So0ysi1zIlBHjKQTD6Mv+AqTkNcGQVtljBlDtBotBl\r\nFpN8980QJj7ki0w0wkrRuYf6xZ+rl0ZwxJvcgJH6pMxPxqjuFwhaEHfsc7SO\r\nIac62VM44sA7nQ3k3Y3yCtgYM3kT+R1WzKcUPyWMB68K9xFu1jvreE+RRIMW\r\nFFNBo1y7jrJro++/CUUfALsNVRxUY4/aAD0wXTUiOYhYuSjcbsdGgmlu19bD\r\n8/DWtMyY8o5N6RvXFPe7xg3dCOWlQuzdr3Pp8FEtXBBLt4Q7CxaFoSNMSUkg\r\nRqqME6mUkBHe5v36KbZaI216ZLerOGrD2j4MJ6yKeeHNTJaV+NpZGsRLk9ow\r\niuS4sENhzP7YahZDATytxTbeP+rUH5NyHEso7upRv8s4ga8WBs0x5VVMEAWu\r\n7GKgYBVXMFIzGcpdUkndIjBR0De2hlStBEriPz5Sin6SyuvY59F+m0orToqu\r\nH2J/0/FZfIfsew4ZNTfAPmVZnPjH5U8tJW4=\r\n=Oysw\r\n-----END PGP SIGNATURE-----\r\n","size":3384,"noattachment":false,"key":"/nice-grpc-client-middleware-deadline/-/nice-grpc-client-middleware-deadline-1.1.2.tgz"},"main":"lib/index.js","gitHead":"1eae2167ee0eeb1e7ab0f56278716b59269ffe46","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.14.2+x64 (darwin)","description":"Deadline client middleware for nice-grpc","directories":{},"_nodeVersion":"16.14.2","dependencies":{"nice-grpc-common":"^1.1.0","node-abort-controller":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"nice-grpc":"^1.2.2","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.1.2_1659325951112_0.1676026489719864","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":1659325951332,"_cnpm_publish_time":1659325951332,"dist-tags":{"latest":"2.0.21"}}