{"_id":"@eeston/grpc-caller","_rev":"6-c97c362d026dbe4a9b6e376108a59113","name":"@eeston/grpc-caller","dist-tags":{"latest":"0.21.0"},"versions":{"0.20.0":{"name":"@eeston/grpc-caller","version":"0.20.0","keywords":["protocol buffer","protobuf","grpc","client"],"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"Apache-2.0","_id":"@eeston/grpc-caller@0.20.0","maintainers":[{"name":"eeston","email":"john@easton.dev"}],"contributors":[{"name":"John Easton","email":"john@easton.dev"}],"homepage":"https://github.com/eeston/grpc-caller","bugs":{"url":"https://github.com/eeston/grpc-caller/issues"},"ava":{"files":["test/*.test.js"]},"dist":{"shasum":"08695c38a74e1984d13a4837fe70159dc1583ede","tarball":"https://registry.npmjs.org/@eeston/grpc-caller/-/grpc-caller-0.20.0.tgz","fileCount":12,"integrity":"sha512-ImwBYBJAYq6W2LRMfnVEjP0yVGkUhZ+hnzIWIXpQNBUXZZpNbzi0qTCDeO8qzexMG9GGaewogfCznPho3ogBSA==","signatures":[{"sig":"MEUCIH/ZFLzaBRvzY29QO7YNfa15m0g8rYiYd01M1wGoMOqrAiEAjVrLt4QgHCMQW4rrfM8S9ceDJkjx4pRAcA1oWEfrc4A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":51590,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWobmCRA9TVsSAnZWagAAPjAP/19vuMJW+bgILtX91ymN\nIDDiriU+brsWvd81F8R7zE953TCxLpCxZxEsI4j6ZY6femRpDQO1FqrBmaM/\n7DSD2GFnBoucB1TsGBhkvVZ+C99GYNgAMJJb8tzSmgKELmaSKvOapPtKUWye\nFRSzHzK1oWMMZ2ohKToZ3/CJUPlPuRbkUAnJVpoDU2KQMU5UH5/zwqfmGp1Q\nzwdXUIZ37jo8FBouUxCoQ4hNj2jQO8kb03pYjrsh7E2DoE5NkR8Af9QqGgFZ\nUm4Wo7jW83RLRhPRQQG16dt5HfaVx1Ytxg+4Vx77fNKH92PKa9nw0vjEqhEm\nlvL+g5O0MNrAIpOKeg0SfWJ1IAXa1tnyfUGD9SvfsIyLAvTsLtjW9p6JK97K\na9bSXvYatmd2Z5cUqr9HNF+u57WcskZPsGqW1WRDRs4JTypA3bf6UxCOLYwq\nOIY1wbRSeB0vEL8NEC5xKuJaDCN/X0cfLR7ATuRYQAnU8fYEjR93RoLAjDVM\nimzbgdKVrH/DE+GJAu1cNcFBjFP9qcmbWjBQEwThC7SGC794CBDZ2xWuNtlW\nWaQMQu4QDIiTAnlC4x5oHLanwC0A/h2sBNry0C3yHYGbRQHWsJ9FjNu7HpTH\noeSx+62j6Ug4t4xSi5jV+0SrsWzIR56qvEIeIzwjiC6ZPMxJ9gie95SAmfJs\nJeMx\r\n=LTTf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","engines":{"node":">=12.0.0"},"gitHead":"4edefeacff46557376a43a937ca62a1dcd8436c1","scripts":{"docs":"jsdoc2md lib/*.js --heading-depth 3 --template readme.hbs > README.md","test":"ava -v","commit":"git-cz","lint.fix":"standard --fix"},"_npmUser":{"name":"eeston","email":"john@easton.dev"},"standard":{"ignore":["**/*_pb.js"]},"repository":{"url":"git+https://github.com/eeston/grpc-caller.git","type":"git"},"_npmVersion":"6.14.11","description":"An improved Node.js gRPC client","directories":{"test":"test"},"_nodeVersion":"14.16.0","dependencies":{"async":"^3.2.0","lodash":"^4.17.14","grpc-inspect":"^0.6.0","call-me-maybe":"^1.0.1","promisify-call":"^2.0.0","@grpc/proto-loader":"^0.5.6","grpc-create-metadata":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.15.0","git-cz":"^4.7.6","standard":"^16.0.3","@grpc/grpc-js":"^1.2.10","google-protobuf":"^3.8.0","jsdoc-to-markdown":"^5.0.0","greenkeeper-lockfile":"^1.15.0"},"peerDependencies":{"@grpc/grpc-js":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/grpc-caller_0.20.0_1616545509717_0.05875207798557569","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.20.2":{"name":"@eeston/grpc-caller","version":"0.20.2","keywords":["protocol buffer","protobuf","grpc","client"],"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"Apache-2.0","_id":"@eeston/grpc-caller@0.20.2","maintainers":[{"name":"eeston","email":"john@easton.dev"}],"contributors":[{"name":"John Easton","email":"john@easton.dev"}],"homepage":"https://github.com/eeston/grpc-caller","bugs":{"url":"https://github.com/eeston/grpc-caller/issues"},"ava":{"files":["test/*.test.js"]},"dist":{"shasum":"3833f45f4079caef51a2bf5cbdfb4b6afd2350ec","tarball":"https://registry.npmjs.org/@eeston/grpc-caller/-/grpc-caller-0.20.2.tgz","fileCount":8,"integrity":"sha512-NmuA1+WQnCCW1Sag/H0vXruz7AvZpYwHi2O/cp046HRpS2zQb5sUwWRmcP62p1X+oF08grXlLZcjczjuGFAwzA==","signatures":[{"sig":"MEUCIG0003AD3M66xxxuB/aoqk2g1xTrKhQ5vo+GdsZ4z06GAiEAn7cxJeBowrrIYszLqnA5+GUSmnWnPgOG7pWoKynftyY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43947,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWwu4CRA9TVsSAnZWagAAhocP/1oHOW2Iw4zYIZj++qOc\nIeKWX3aoKn6X+QS9dkqhXe0dLf4S3g6oLevE5jh4yGp3Lqmm91ItJGavFrIz\nVxLY9t764ZQpIGy4cUqvZGaIvZA3LU+Qc7ipwVYAap+exJ49dxgsSxQHXlWp\neO7v65dUTcgbocZV7LK9WH6ob9WDBnlsEbIICC/9Bh4B2k2hEw7SH1+mg2aq\n84zDsKIBzFIFudeTPf8hIa0vT5SyyUytdasNvlmaYeu+WToVkbwxLRUQfk0M\nYUO5XUCvNyfiEORSvnJfbRZtziraK6OrzEuqN1o2pHgv0jej47nA8UzbPXjK\nUWD88fFe+JOIlNEJZ2AermjdoOIhJrsSY0z6ysKI2co7AiiYztECUC1zNVpu\ndxMgAMFy7AKEcomtqHTs4EhRSBvSL4SHCP91qFws7cbN+d5bCCiX5vgaU7kz\nlMfDXeNrSZdwunz22N+SDDKrwT09r2/x1JCPfV78r0IwviaBLOb0ZshH54t/\nANeQ92x4nViAPXxPQ3Rqj4vlxOqg9FD5EWs0MkV/GaNuRzx6mD2EwC4xDWns\nXopujP0W0TfyJmJMci1VrxBhE/WVpi5ldRS4j3zWds4DPXih7hBSIpC6cN7r\n8RSDebKidknajchYTfeidbFfVBORA7iDdg3Gpg9jotTbJTBDEno0kHX/8WzV\nyki8\r\n=mDl7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","engines":{"node":">=12.0.0"},"gitHead":"8cd9a2c024fdf4d570634623f38c2f6dca635f31","scripts":{"docs":"jsdoc2md lib/*.js --heading-depth 3 --template readme.hbs > README.md","test":"ava -v","commit":"git-cz","lint.fix":"standard --fix"},"_npmUser":{"name":"eeston","email":"john@easton.dev"},"standard":{"ignore":["**/*_pb.js"]},"repository":{"url":"git+https://github.com/eeston/grpc-caller.git","type":"git"},"_npmVersion":"6.14.11","description":"An improved Node.js gRPC client","directories":{"test":"test"},"_nodeVersion":"14.16.0","dependencies":{"async":"^3.2.0","lodash":"^4.17.14","grpc-inspect":"^0.6.0","call-me-maybe":"^1.0.1","promisify-call":"^2.0.0","@grpc/proto-loader":"^0.5.6","grpc-create-metadata":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.15.0","git-cz":"^4.7.6","standard":"^16.0.3","@grpc/grpc-js":"^1.2.10","google-protobuf":"^3.8.0","jsdoc-to-markdown":"^5.0.0","greenkeeper-lockfile":"^1.15.0"},"peerDependencies":{"@grpc/grpc-js":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/grpc-caller_0.20.2_1616579511461_0.12743619432433695","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.20.3":{"name":"@eeston/grpc-caller","version":"0.20.3","keywords":["protocol buffer","protobuf","grpc","client"],"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"Apache-2.0","_id":"@eeston/grpc-caller@0.20.3","maintainers":[{"name":"eeston","email":"john@easton.dev"}],"contributors":[{"name":"John Easton","email":"john@easton.dev"}],"homepage":"https://github.com/eeston/grpc-caller","bugs":{"url":"https://github.com/eeston/grpc-caller/issues"},"ava":{"files":["test/*.test.js"]},"dist":{"shasum":"67b3021984c40d79df569a38ec6b6dacba40df92","tarball":"https://registry.npmjs.org/@eeston/grpc-caller/-/grpc-caller-0.20.3.tgz","fileCount":7,"integrity":"sha512-nw9yQqoONFIe/ri98sNBx7xHc9cLBVKPvcb6sr78uZmaQeAgxptI1eHZBtlOqbktBN9iks6i/3Aq29rEBZDRHw==","signatures":[{"sig":"MEQCIHL4Jt0hgy2uNrhn0k63f2q8vU5maZQzd2w5CR6Cq5CvAiB9nQ++4P6hvUzNEWuy9iTf1Gkf5eYPqEhgsMZgTjjc8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43844,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgnPgPCRA9TVsSAnZWagAAR7cQAJi29qKOfe21FyGyiZNN\nAZSszM346H8BFzbpFw+ikIyf88kVHjNjrErdhYeyv2BfTPvj3OkXpmqxPYbS\n8X2E+aaTP1cpscd3emOntLIftYa6fwn5kfgF9YHhxR2P/UF791YrMyQ+IEpr\n3xC665ieOCARwLP4GAOxMcJfGIqnxdBHUhTtG3ysp1XoPKMReEX+2KFpzW8m\nlVQDNZbcLti3Es6zR7gVQts/Zt58Omr3AECfl6g/cDbxdxpzWy+o6H8mXBWa\nJq/2t1vyjIcrn5l3rwubJRkf2m9N1AYPd7aLnrkzpr0hLyrL2/IiBUllWOQY\nFRQpmb980XECmy3mWjmu2KjBMK1ZAxE05tH3yUSkYlEinYMFGntH3nGlbPg+\nDqKfkjzHHdZyxrwqHe5bLUlXlg5uOEfEattah2jbQhKxa6QnUjWIgNHGdNka\nkjFXsRiUUrDY6kjRbkpVqjcG0+PPszZyeRra8I/eybOKpbQuA6vKhFCodPpK\n3k09lZGmzJcFfbKhNqcDA5ImKBnWN35/lCM+Rjb4iHaC14NAHO3gDLu0iufy\njopgWlMxNvpaqnPKKjsEo8zQe9JI6VZLOVnEE+GCWr84Xti30A2+yju1rlLv\nTGeEoa+vOpWTTXTIqveD/hyPlgGQwIz2bIkpiBALIaatX/LBZzTnzjCrtcxq\nMx+A\r\n=n2LC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","engines":{"node":">=12.0.0"},"gitHead":"8b1674b01ce6ef1ede6016cc866edc908db8993f","scripts":{"docs":"jsdoc2md lib/*.js --heading-depth 3 --template readme.hbs > README.md","test":"ava -v","commit":"git-cz","lint.fix":"standard --fix"},"_npmUser":{"name":"eeston","email":"john@easton.dev"},"standard":{"ignore":["**/*_pb.js"]},"repository":{"url":"git+https://github.com/eeston/grpc-caller.git","type":"git"},"_npmVersion":"6.14.12","description":"An improved Node.js gRPC client","directories":{"test":"test"},"_nodeVersion":"14.16.1","dependencies":{"async":"^3.2.0","lodash":"^4.17.14","grpc-inspect":"^0.6.0","call-me-maybe":"^1.0.1","promisify-call":"^2.0.0","@grpc/proto-loader":"^0.5.6","grpc-create-metadata":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.15.0","git-cz":"^4.7.6","standard":"^16.0.3","@grpc/grpc-js":"^1.2.10","google-protobuf":"^3.8.0"},"peerDependencies":{"@grpc/grpc-js":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/grpc-caller_0.20.3_1620899855117_0.206280928574601","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"0.21.0":{"name":"@eeston/grpc-caller","version":"0.21.0","keywords":["protocol buffer","protobuf","grpc","client"],"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"Apache-2.0","_id":"@eeston/grpc-caller@0.21.0","maintainers":[{"name":"eeston","email":"accounts+npm@easton.dev"}],"contributors":[{"name":"John Easton","email":"john@easton.dev"}],"homepage":"https://github.com/eeston/grpc-caller","bugs":{"url":"https://github.com/eeston/grpc-caller/issues"},"ava":{"files":["test/*.test.js"]},"dist":{"shasum":"a427fd5c96f951405b8673d78180056c8d61da46","tarball":"https://registry.npmjs.org/@eeston/grpc-caller/-/grpc-caller-0.21.0.tgz","fileCount":7,"integrity":"sha512-hZoDG3djbLhGvGYoaHkOYkrv1PQ84YsE1IwDIQaXx55TNZSwXSt2ChutoZmhFu5TOWPE6axL4NiXR0Lvb92/SA==","signatures":[{"sig":"MEYCIQCg3DC56cAqwRxprtdKHJc9tRjkBBI2e2CmwESbgUarjgIhAJUCHRD9ebU9VlhC8/zfCKSvCXqE4JQjKRrETdL28fPO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43844,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgxMPhCRA9TVsSAnZWagAAmaYP/1TUQWBb68pw4Iu8PXp4\nOV6XW1ZPfttMoBWjxwwpuF3Lsy9f2J0WsZTbaMaXS64rMTvIrBUCDLlYsCGz\nLfU5moOtbIJqJ44JNgutLU0PS8tbzUGCOxBFZfNMXLpu0pzbei6UQs7Fslix\nYC8StYOCcMV8u7wl7gPem8lvLt1xbVbWu/LCmKRjqluF16DTfhXH1xIaA+0N\n2ZkjH6iQU3CQKnKSuyirm6/9kPheHplXz9zcl3Hv4JW3xbjJaH/xv5ZayhAa\nAdnCI8faa5YmvayV/FNH1W5OxS8HgOTVxoZaWQiISAE3mtLiL1hRHplk85py\ngvhS2naH58++heFDyEqbL+8XvqWkK6WQI3Fk1JYr1Sf7lVsoiRFfsnMj8v7i\n3aw/Ixwn3QJTXFqajQtgVozXNzFLY6XYRPdFZafeQhRw85ODGUBktY2lREoB\nJ+qcrHeowRW5s6ZLHLBN4VADjBWShWcx2xTqsRtu6AvMsE/t+FOn0JKIsdhj\ntmcI7b3xJq2pVvWpHixTUjXTLTNBmqgMmaW2/UUfceGssSfhvBkZuobqVN27\naPQSlDo3E7PVRye9bNsuQ0HCyQqq1WuAnmFf6yJLDhMxD7TJGKWXCkzccs8m\n20Xn6eoO1rMsGFS+1BjW3s8VkmmyosIr4Krqei1htXnGvUJMTww8pJRFUR92\nP3uD\r\n=GFOJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","engines":{"node":">=14.0.0"},"gitHead":"e268cad3f435116a3a60f0533f1202efd37f1819","scripts":{"docs":"jsdoc2md lib/*.js --heading-depth 3 --template readme.hbs > README.md","test":"ava -v","commit":"git-cz","lint.fix":"standard --fix"},"_npmUser":{"name":"eeston","email":"accounts+npm@easton.dev"},"standard":{"ignore":["**/*_pb.js"]},"repository":{"url":"git+https://github.com/eeston/grpc-caller.git","type":"git"},"_npmVersion":"6.14.13","description":"An improved Node.js gRPC client","directories":{"test":"test"},"_nodeVersion":"14.17.0","dependencies":{"async":"^3.2.0","lodash":"^4.17.14","grpc-inspect":"^0.6.0","call-me-maybe":"^1.0.1","promisify-call":"^2.0.0","@grpc/proto-loader":"^0.6.2","grpc-create-metadata":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.15.0","git-cz":"^4.7.6","standard":"^16.0.3","@grpc/grpc-js":"^1.3.2","google-protobuf":"^3.17.3"},"peerDependencies":{"@grpc/grpc-js":"^1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/grpc-caller_0.21.0_1623507937595_0.812432814256804","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2021-03-24T00:25:09.673Z","modified":"2026-09-19T16:38:13.730Z","0.20.0":"2021-03-24T00:25:10.005Z","0.20.2":"2021-03-24T09:51:51.599Z","0.20.3":"2021-05-13T09:57:35.353Z","0.21.0":"2021-06-12T14:25:37.721Z"},"bugs":{"url":"https://github.com/eeston/grpc-caller/issues"},"author":{"name":"Bojan D.","email":"dbojan@gmail.com"},"license":"Apache-2.0","homepage":"https://github.com/eeston/grpc-caller","keywords":["protocol buffer","protobuf","grpc","client"],"repository":{"url":"git+https://github.com/eeston/grpc-caller.git","type":"git"},"description":"An improved Node.js gRPC client","contributors":[{"name":"John Easton","email":"john@easton.dev"}],"maintainers":[{"name":"eeston","email":"accounts+npm@easton.dev"}],"readme":"# grpc-caller\n\nAn improved [gRPC](http://www.grpc.io) client.\n\nThis forked repository aims to provide a `@grpc/grpc-js` compatable version of [grpc-caller](https://github.com/bojand/grpc-caller). The original repository relies on `grpc` which is [no longer supported](https://grpc.io/blog/grpc-js-1.0/).\n\n[![npm version](https://img.shields.io/npm/v/@eeston/grpc-caller.svg?style=flat-square)](https://www.npmjs.com/package/@eeston/grpc-caller)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)\n[![License](https://img.shields.io/github/license/bojand/grpc-caller.svg?style=flat-square)](https://raw.githubusercontent.com/bojand/grpc-caller/master/LICENSE)\n\n[![Node.js CI](https://github.com/eeston/grpc-caller/actions/workflows/nodejs.yml/badge.svg?branch=master)](https://github.com/eeston/grpc-caller/actions/workflows/nodejs.yml)\n[![CodeQL](https://github.com/eeston/grpc-caller/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/eeston/grpc-caller/actions/workflows/codeql-analysis.yml)\n\n#### Features\n\n- Promisifies request / response (Unary) calls if no callback is supplied\n- Promisifies request stream / response calls if no callback is supplied\n- Automatically converts plain javascript object to metadata in calls.\n- Adds optional retry functionality to request / response (Unary) calls.\n- Exposes expanded `Request` API for collecting metadata and status.\n\n## Installation\n\n```\n$ npm install @eeston/grpc-caller\n```\n\n## Overview\n\n#### Improved unary calls\n\nWorks as standard gRPC client:\n\n```js\nconst caller = require(\"grpc-caller\");\nconst PROTO_PATH = path.resolve(__dirname, \"./protos/helloworld.proto\");\nconst client = caller(\"0.0.0.0:50051\", PROTO_PATH, \"Greeter\");\nclient.sayHello({ name: \"Bob\" }, (err, res) => {\n  console.log(res);\n});\n```\n\nFor unary calls, also promisified if callback is not provided:\n\n```js\nclient.sayHello({ name: \"Bob\" }).then((res) => console.log(res));\n```\n\nWhich means means you can use is with `async / await`\n\n```js\nconst res = await client.sayHello({ name: \"Bob\" });\nconsole.log(res);\n```\n\nFor Unary calls we expose `retry` option identical to [async.retry](http://caolan.github.io/async/docs.html#retry).\n\n```\nconst res = await client.sayHello({ name: 'Bob' }, {}, { retry: 3 })\nconsole.log(res)\n```\n\n#### Improved request stream / response calls\n\nLets say we have a remote call `writeStuff` that accepts a stream of messages\nand returns some result based on processing of the stream input.\n\nWorks as standard gRPC client:\n\n```js\nconst call = client.writeStuff((err, res) => {\n  if (err) console.error(err);\n  console.log(res);\n});\n\n// ... write stuff to call\n```\n\nIf no callback is provided we promisify the call such that it returns an **object\nwith two properties** `call` and `res` such that:\n\n- `call` - the standard stream to write to as returned normally by grpc\n- `res` - a promise that's resolved / rejected when the call is finished, in place of the callback.\n\nUsing destructuring we can do something like:\n\n```js\nconst { call, res } = client.writeStuff();\nres.then((res) => console.log(res)).catch((err) => console.error(err));\n\n// ... write stuff to call\n```\n\nThis means we can abstract the whole operation into a nicer promise returning\nasync function to use with `async / await`\n\n```js\nasync function writeStuff() {\n  const { call, res } = client.writeStuff();\n  // ... write stuff to call\n  return res;\n}\n\nconst res = await writeStuff();\nconsole.log(res);\n```\n\n#### Automatic `Metadata` creation\n\nAll standard gRPC client calls accept [`Metadata`](http://www.grpc.io/grpc/node/module-src_metadata-Metadata.html)\nas first or second parameter (depending on the call type). However one has to\nmanually create the Metadata object. This module uses\n[grpc-create-metadata](https://www.github.com/bojand/grpc-create-metadata)\nto automatically create Metadata if plain Javascript object is passed in.\n\n```js\n// the 2nd parameter will automatically be converted to gRPC Metadata and\n// included in the request\nconst res = await client.sayHello(\n  { name: \"Bob\" },\n  { requestid: \"my-request-id-123\" }\n);\nconsole.log(res);\n```\n\nWe can still pass an actual `Metadata` object and it will be used as is:\n\n```js\nconst meta = new grpc.Metadata();\nmeta.add(\"requestid\", \"my-request-id-123\");\nconst res = await client.sayHello({ name: \"Bob\" }, meta);\nconsole.log(res);\n```\n\n## Request API\n\nIn addition to simple API above, the library provides a more detailed `\"Request\"` API that can\nbe used to control the call details. The API can only be used for Unary and\nrequest streaming calls.\n\n#### Unary calls\n\n```js\nconst req = new client.Request(\"sayHello\", { name: \"Bob\" }) // call method name and argument\n  .withMetadata({ requestId: \"bar-123\" }) // call request metadata\n  .withResponseMetadata(true) // we want to collect response metadata\n  .withResponseStatus(true) // we want to collect the response status\n  .withRetry(5); // retry options\n\nconst res = await req.exec();\n// res is an instance of our `Response`\n// we can also call exec() using a callback\n\nconsole.log(res.response); // the actual response data { message: 'Hello Bob!' }\nconsole.log(res.metadata); // the response metadata\nconsole.log(res.status); // the response status\nconsole.log(res.call); // the internal gRPC call\n```\n\n#### Request streaming calls\n\nIn case of request streaming calls if `exec()` is called with a callback the gRPC `call` stream is returned.\nIf no callback is provided an object is returned with `call` property being the call stream and `res`\nproperty being a Promise fulfilled when the call is completed. There is no `retry` option for\nrequest streaming calls.\n\n```js\nconst req = new client.Request(\"writeStuff\") // the call method name\n  .withMetadata({ requestId: \"bar-123\" }) // the call request metadata\n  .withResponseMetadata(true) // we want to collect response metadata\n  .withResponseStatus(true); // we want to collect the response status\n\nconst { call, res: resPromise } = req.exec();\n\n// ... write data to call\n\nconst res = await resPromise; // res is our `Response`\n\nconsole.log(res.response); // the actual response data\nconsole.log(res.metadata); // the response metadata\nconsole.log(res.status); // the response status\nconsole.log(res.call); // the internal gRPC call\n```\n\n## API Reference\n\n<a name=\"Request\"></a>\n\n### Request\n\nA Request class that encapsulates the request of a call.\n\n**Kind**: global class\n\n- [Request](#Request)\n  - [new Request(methodName, param)](#new_Request_new)\n  - [.withGrpcOptions(opts)](#Request+withGrpcOptions) ⇒ <code>Object</code>\n  - [.withMetadata(opts)](#Request+withMetadata) ⇒ <code>Object</code>\n  - [.withRetry(retry)](#Request+withRetry) ⇒ <code>Object</code>\n  - [.withResponseMetadata(value)](#Request+withResponseMetadata) ⇒ <code>Object</code>\n  - [.withResponseStatus(value)](#Request+withResponseStatus) ⇒ <code>Object</code>\n  - [.exec(fn)](#Request+exec) ⇒ <code>Promise</code> \\| <code>Object</code>\n\n<a name=\"new_Request_new\"></a>\n\n#### new Request(methodName, param)\n\nCreates a Request instance.\n\n| Param      | Type                | Description                                 |\n| ---------- | ------------------- | ------------------------------------------- |\n| methodName | <code>String</code> | the method name.                            |\n| param      | <code>\\*</code>     | the call argument in case of `UNARY` calls. |\n\n<a name=\"Request+withGrpcOptions\"></a>\n\n#### request.withGrpcOptions(opts) ⇒ <code>Object</code>\n\nCreate a request with call options.\n\n**Kind**: instance method of [<code>Request</code>](#Request)  \n**Returns**: <code>Object</code> - the request instance.\n\n| Param | Type                | Description            |\n| ----- | ------------------- | ---------------------- |\n| opts  | <code>Object</code> | The gRPC call options. |\n\n<a name=\"Request+withMetadata\"></a>\n\n#### request.withMetadata(opts) ⇒ <code>Object</code>\n\nCreate a request with call metadata.\n\n**Kind**: instance method of [<code>Request</code>](#Request)  \n**Returns**: <code>Object</code> - the request instance.\n\n| Param | Type                | Description                                                                             |\n| ----- | ------------------- | --------------------------------------------------------------------------------------- |\n| opts  | <code>Object</code> | The gRPC call metadata. Can either be a plain object or an instance of `grpc.Metadata`. |\n\n<a name=\"Request+withRetry\"></a>\n\n#### request.withRetry(retry) ⇒ <code>Object</code>\n\nCreate a request with retry options.\n\n**Kind**: instance method of [<code>Request</code>](#Request)  \n**Returns**: <code>Object</code> - the request instance.\n\n| Param | Type                                       | Description                                    |\n| ----- | ------------------------------------------ | ---------------------------------------------- |\n| retry | <code>Number</code> \\| <code>Object</code> | The retry options. Identical to `async.retry`. |\n\n<a name=\"Request+withResponseMetadata\"></a>\n\n#### request.withResponseMetadata(value) ⇒ <code>Object</code>\n\nCreate a request indicating whether we want to collect the response metadata.\n\n**Kind**: instance method of [<code>Request</code>](#Request)  \n**Returns**: <code>Object</code> - the request instance.\n\n| Param | Type                 | Description                                               |\n| ----- | -------------------- | --------------------------------------------------------- |\n| value | <code>Boolean</code> | `true` to collect the response metadata. Default `false`. |\n\n<a name=\"Request+withResponseStatus\"></a>\n\n#### request.withResponseStatus(value) ⇒ <code>Object</code>\n\nCreate a request indicating whether we want to collect the response status metadata.\n\n**Kind**: instance method of [<code>Request</code>](#Request)  \n**Returns**: <code>Object</code> - the request instance.\n\n| Param | Type                 | Description                                                      |\n| ----- | -------------------- | ---------------------------------------------------------------- |\n| value | <code>Boolean</code> | `true` to collect the response status metadata. Default `false`. |\n\n<a name=\"Request+exec\"></a>\n\n#### request.exec(fn) ⇒ <code>Promise</code> \\| <code>Object</code>\n\nExecute the request.\n\n**Kind**: instance method of [<code>Request</code>](#Request)  \n**Returns**: <code>Promise</code> \\| <code>Object</code> - If no callback is provided in case of `UNARY` call a Promise is returned.\nIf no callback is provided in case of `REQUEST_STREAMING` call an object is\nreturned with `call` property being the call stream and `res`\nproperty being a Promise fulfilled when the call is completed.\n\n| Param | Type                  | Description       |\n| ----- | --------------------- | ----------------- |\n| fn    | <code>function</code> | Optional callback |\n\n<a name=\"Response\"></a>\n\n### Response\n\nA Response class that encapsulates the response of a call using the `Request` API.\n\n**Kind**: global class\n\n- [Response](#Response)\n  - [.call](#Response+call) : <code>Object</code>\n  - [.response](#Response+response) : <code>Object</code>\n  - [.metadata](#Response+metadata) : <code>Object</code>\n  - [.status](#Response+status) : <code>Object</code>\n\n<a name=\"Response+call\"></a>\n\n#### response.call : <code>Object</code>\n\nThe response's gRPC call.\n\n**Kind**: instance property of [<code>Response</code>](#Response)  \n<a name=\"Response+response\"></a>\n\n#### response.response : <code>Object</code>\n\nThe actual response data from the call.\n\n**Kind**: instance property of [<code>Response</code>](#Response)  \n<a name=\"Response+metadata\"></a>\n\n#### response.metadata : <code>Object</code>\n\nThe response metadata.\n\n**Kind**: instance property of [<code>Response</code>](#Response)  \n<a name=\"Response+status\"></a>\n\n#### response.status : <code>Object</code>\n\nThe response status metadata.\n\n**Kind**: instance property of [<code>Response</code>](#Response)  \n<a name=\"caller\"></a>\n\n### caller(host, proto, name, credentials, options, defaults) ⇒ <code>Object</code>\n\nCreate client isntance.\n\n**Kind**: global function\n\n| Param         | Type                                       | Description                                                                                                                                                                                                                  |\n| ------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| host          | <code>String</code>                        | The host to connect to                                                                                                                                                                                                       |\n| proto         | <code>String</code> \\| <code>Object</code> | Path to the protocol buffer definition file or Object specifying <code>file</code> to load and <code>load</code> options for proto loader.                                                                                   |\n| name          | <code>String</code>                        | In case of proto path the name of the service as defined in the proto definition.                                                                                                                                            |\n| credentials   | <code>Object</code>                        | The credentials to use to connect. Defaults to `grpc.credentials.createInsecure()`                                                                                                                                           |\n| options       | <code>Object</code>                        | Options to be passed to the gRPC client constructor                                                                                                                                                                          |\n| options.retry | <code>Object</code>                        | In addition to gRPC client constructor options, we accept a `retry` option. The retry option is identical to `async.retry` and is passed as is to it. This is used only for `UNARY` calls to add automatic retry capability. |\n| defaults      | <code>Object</code>                        | Metadata and Options that will be passed to every Request                                                                                                                                                                    |\n\n**Example** _(Create client dynamically)_\n\n```js\nconst PROTO_PATH = path.resolve(__dirname, \"./protos/helloworld.proto\");\nconst client = caller(\"localhost:50051\", PROTO_PATH, \"Greeter\");\n```\n\n**Example** _(With options)_\n\n```js\nconst file = path.join(__dirname, \"helloworld.proto\");\nconst load = {\n  // ... proto-loader load options\n};\nconst client = caller(\"localhost:50051\", { file, load }, \"Greeter\");\n```\n\n**Example** _(Create a static client)_\n\n```js\nconst services = require(\"./static/helloworld_grpc_pb\");\nconst client = caller(\"localhost:50051\", services.GreeterClient);\n```\n\n**Example** _(Pass Options, Default Metadata and Interceptor options)_\n\n```js\nconst metadata = { node_id: process.env.CLUSTER_NODE_ID };\nconst credentials = grpc.credentials.createInsecure()\nconst options = {\n  interceptors = [ bestInterceptorEver ]\n}\nconst client = caller('localhost:50051', PROTO_PATH, 'Greeter', credentials, options, {\n  metadata: { foo: 'bar' }\n})\n\n// Now every call with that client will result\n// in invoking the interceptor and sending the default metadata\n```\n\n- [caller(host, proto, name, credentials, options, defaults)](#caller) ⇒ <code>Object</code>\n  - [.metadata](#caller.metadata)\n  - [.wrap](#caller.wrap)\n\n<a name=\"caller.metadata\"></a>\n\n#### caller.metadata\n\nUtility helper function to create <code>Metadata</code> object from plain Javascript object.\nSee <code>grpc-create-metadata</code> module.\n\n**Kind**: static property of [<code>caller</code>](#caller)  \n<a name=\"caller.wrap\"></a>\n\n#### caller.wrap\n\nUtility function that can be used to wrap an already constructed client instance.\n\n**Kind**: static property of [<code>caller</code>](#caller)\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md"}