grpc-helper
Advanced tools
Comparing version 0.0.0 to 0.1.0
{ | ||
"name": "grpc-helper", | ||
"version": "0.0.0", | ||
"description": "Please wait", | ||
"main": "index.js", | ||
"version": "0.1.0", | ||
"description": "grpc helper", | ||
"main": "dist/src/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "ava", | ||
"coverage": "nyc npm test", | ||
"lint": "tslint --format prose src/**/*.ts test/**/*.ts", | ||
"coverage-ci": "nyc npm test && nyc report --reporter=text-lcov | coveralls", | ||
"build": "tsc", | ||
"clean": "rm -rf dist", | ||
"prebuild": "npm run clean", | ||
"postbuild": "cp src/*.proto dist/src && cp test/*.proto dist/test && cp -r test/fixtures dist/test", | ||
"prepublish": "npm run build" | ||
}, | ||
"keywords": [], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/xizhibei/grpc-helper.git" | ||
}, | ||
"author": "Xu Zhipei <xuzhipei@gmail.com>", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"files": [ | ||
"dist/src" | ||
], | ||
"typings": "dist/src/index.d.ts", | ||
"keywords": [ | ||
"grpc", | ||
"helper", | ||
"promise", | ||
"load-balancer", | ||
"typescript" | ||
], | ||
"ava": { | ||
"compileEnhancements": false, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
] | ||
}, | ||
"nyc": { | ||
"extension": [ | ||
".ts" | ||
], | ||
"reporter": [ | ||
"lcov", | ||
"text-summary" | ||
], | ||
"include": [ | ||
"dist/src" | ||
], | ||
"all": true | ||
}, | ||
"dependencies": { | ||
"@grpc/proto-loader": "^0.3.0", | ||
"bluebird": "^3.5.0", | ||
"brakes": "^2.6.0", | ||
"debug": "^3.1.0", | ||
"grpc": "^1.14.1", | ||
"lodash": "^4.17.10", | ||
"prom-client": "^10.2.3" | ||
}, | ||
"devDependencies": { | ||
"@types/bluebird-global": "^3.5.3", | ||
"@types/debug": "^0.0.30", | ||
"@types/lodash": "^4.14.91", | ||
"@types/node": "^10.9.3", | ||
"ava": "^0.25.0", | ||
"coveralls": "^3.0.2", | ||
"mock-require": "^3.0.2", | ||
"nyc": "^11.9.0", | ||
"ts-node": "^7.0.1", | ||
"tslint": "^5.8.0", | ||
"typescript": "^3.0.1" | ||
} | ||
} |
117
Readme.md
@@ -1,3 +0,116 @@ | ||
# Please wait | ||
# GRPC helper | ||
for latter publish | ||
**WARNING: in beta !!!** | ||
[![Build Status](https://travis-ci.org/xizhibei/grpc-helper.svg?branch=master&style=flat)](https://travis-ci.org/xizhibei/grpc-helper) | ||
[![Coverage Status](https://coveralls.io/repos/github/xizhibei/grpc-helper/badge.svg?branch=master)](https://coveralls.io/github/xizhibei/grpc-helper?branch=master) | ||
[![npm version](https://badge.fury.io/js/grpc-helper.svg?style=flat)](http://badge.fury.io/js/grpc-helper) | ||
[![Dependency Status](https://img.shields.io/david/xizhibei/grpc-helper.svg?style=flat)](https://david-dm.org/xizhibei/grpc-helper) | ||
[![npm](https://img.shields.io/npm/l/grpc-helper.svg)](https://github.com/xizhibei/grpc-helper/blob/master/LICENSE) | ||
### Getting Started | ||
### Installing | ||
```bash | ||
npm i grpc-helper --save | ||
``` | ||
or | ||
```bash | ||
yarn add grpc-helper | ||
``` | ||
### Features | ||
- Promised unary & client stream call | ||
- Client Load balance | ||
- Service health checking | ||
- Service discovery (static, dns srv) | ||
- Circuit breaker | ||
### Usage | ||
#### DNS Service discovery | ||
```ts | ||
const helper = new GRPCHelper({ | ||
packageName: 'helloworld', | ||
serviceName: 'Greeter', | ||
protoPath: path.resolve(__dirname, './hello.proto'), | ||
sdUri: 'dns://_http._tcp.greeter', | ||
}); | ||
await helper.waitForReady(); | ||
const res = await helper.SayHello({ | ||
name: 'foo', | ||
}); | ||
``` | ||
#### Static Service discovery | ||
```ts | ||
const helper = new GRPCHelper({ | ||
packageName: 'helloworld', | ||
serviceName: 'Greeter', | ||
protoPath: path.resolve(__dirname, './hello.proto'), | ||
sdUri: 'static://localhost:50051,localhost:50052,localhost:50053', | ||
}); | ||
await helper.waitForReady(); | ||
const res = await helper.SayHello({ | ||
name: 'foo', | ||
}); | ||
``` | ||
#### Resolve with full response | ||
```ts | ||
const helper = new GRPCHelper({ | ||
packageName: 'helloworld', | ||
serviceName: 'Greeter', | ||
protoPath: path.resolve(__dirname, './hello.proto'), | ||
sdUri: 'static://localhost:50051', | ||
resolveFullResponse: true, | ||
}); | ||
await helper.waitForReady(); | ||
const { message, peer, status, metadata } = await helper.SayHello({ | ||
name: 'foo', | ||
}); | ||
``` | ||
#### Client stream call | ||
```ts | ||
const stream = new stream.PassThrough({ objectMode: true }); | ||
const promise = helper.SayMultiHello(stream); | ||
stream.write({ | ||
name: 'foo1', | ||
}); | ||
stream.write({ | ||
name: 'foo2', | ||
}); | ||
stream.write({ | ||
name: 'foo3', | ||
}); | ||
stream.end(); | ||
const result = await promise; | ||
``` | ||
### TODO | ||
- [x] Better api | ||
- [x] Doc | ||
- [x] Test code | ||
- [ ] Consul/etcd/zk service discovery | ||
### License | ||
This project is licensed under the MIT License - see the LICENSE file for details |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
71614
34
1166
2
117
0
7
11
2
+ Added@grpc/proto-loader@^0.3.0
+ Addedbluebird@^3.5.0
+ Addedbrakes@^2.6.0
+ Addeddebug@^3.1.0
+ Addedgrpc@^1.14.1
+ Addedlodash@^4.17.10
+ Addedprom-client@^10.2.3
+ Added@grpc/proto-loader@0.3.0(transitive)
+ Added@mapbox/node-pre-gyp@1.0.11(transitive)
+ Added@protobufjs/aspromise@1.1.2(transitive)
+ Added@protobufjs/base64@1.1.2(transitive)
+ Added@protobufjs/codegen@2.0.4(transitive)
+ Added@protobufjs/eventemitter@1.1.0(transitive)
+ Added@protobufjs/fetch@1.1.0(transitive)
+ Added@protobufjs/float@1.0.2(transitive)
+ Added@protobufjs/inquire@1.1.0(transitive)
+ Added@protobufjs/path@1.1.2(transitive)
+ Added@protobufjs/pool@1.1.0(transitive)
+ Added@protobufjs/utf8@1.1.0(transitive)
+ Added@types/bytebuffer@5.0.49(transitive)
+ Added@types/lodash@4.17.13(transitive)
+ Added@types/long@3.0.324.0.2(transitive)
+ Added@types/node@22.9.19.6.61(transitive)
+ Addedabbrev@1.1.1(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedansi-regex@2.1.15.0.1(transitive)
+ Addedaproba@2.0.0(transitive)
+ Addedare-we-there-yet@2.0.0(transitive)
+ Addedascli@1.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbintrees@1.0.2(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbrakes@2.8.1(transitive)
+ Addedbytebuffer@5.0.1(transitive)
+ Addedcamelcase@2.1.1(transitive)
+ Addedchownr@2.0.0(transitive)
+ Addedcliui@3.2.0(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addedcolour@0.7.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addeddebug@3.2.74.3.7(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@2.0.3(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedfs-minipass@2.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedgauge@3.0.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgrpc@1.24.11(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinvert-kv@1.0.0(transitive)
+ Addedis-fullwidth-code-point@1.0.03.0.0(transitive)
+ Addedlcid@1.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlodash.camelcase@4.3.0(transitive)
+ Addedlodash.clone@4.5.0(transitive)
+ Addedlong@3.2.04.0.0(transitive)
+ Addedmake-dir@3.1.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminipass@3.3.65.0.0(transitive)
+ Addedminizlib@2.1.2(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addedms@2.1.3(transitive)
+ Addednan@2.22.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednopt@5.0.0(transitive)
+ Addednpmlog@5.0.1(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptjs@3.2.2(transitive)
+ Addedos-locale@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprom-client@10.2.3(transitive)
+ Addedprotobufjs@5.0.36.11.4(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver@6.3.17.6.3(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@1.0.24.2.3(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-ansi@3.0.16.0.1(transitive)
+ Addedtar@6.2.1(transitive)
+ Addedtdigest@0.1.2(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedwindow-size@0.1.4(transitive)
+ Addedwrap-ansi@2.1.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@3.2.2(transitive)
+ Addedyallist@4.0.0(transitive)
+ Addedyargs@3.32.0(transitive)