Skip to content

Commit 8542f7e

Browse files
authored
Merge pull request #67 from murgatroid99/grpc-js_support
Rework library to be compatible with grpc-js
2 parents 1e40c4d + 031aaf0 commit 8542f7e

File tree

9 files changed

+1207
-1261
lines changed

9 files changed

+1207
-1261
lines changed

grpc-gcp/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ First, Create a json file defining API configuration, with ChannelPoolConfig and
4949
Load configuration to ApiConfig.
5050

5151
```javascript
52-
var grpcGcp = require('grpc-gcp');
52+
// @grpc/grpc-js can be used in place of grpc with no changes
53+
var grpc = require('grpc');
54+
var grpcGcp = require('grpc-gcp')(grpc);
5355
var fs = require('fs');
5456

5557
var apiDefinition = JSON.parse(fs.readFileSync('your_api_config_json_file'));

grpc-gcp/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "grpc-gcp",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "Extension for supporting Google Cloud Platform specific features for gRPC.",
55
"main": "build/src/index.js",
66
"scripts": {
@@ -35,8 +35,7 @@
3535
"node": ">=6"
3636
},
3737
"dependencies": {
38-
"grpc": "^1.16.0",
39-
"protobufjs": "^6.8.8"
38+
"@grpc/grpc-js": "^0.7.3"
4039
},
4140
"devDependencies": {
4241
"@grpc/proto-loader": "0.4.0",
@@ -45,9 +44,10 @@
4544
"eslint-plugin-node": "8.0.0",
4645
"eslint-plugin-prettier": "3.0.0",
4746
"google-auth-library": "3.1.1",
48-
"google-gax": "0.25.5",
47+
"google-gax": "^1.15.1",
4948
"google-protobuf": "3.7.0",
50-
"grpc-tools": "1.7.1",
49+
"grpc": "^1.24.2",
50+
"grpc-tools": "^1.8.1",
5151
"gts": "0.9.0",
5252
"mocha": "6.0.2",
5353
"nyc": "13.3.0",

grpc-gcp/src/channel_ref.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*
1717
*/
1818

19-
import {Channel} from 'grpc';
19+
import * as grpc from '@grpc/grpc-js';
2020

2121
/**
2222
* A wrapper of real grpc channel. Also provides helper functions to
2323
* calculate affinity counts and active streams count.
2424
*/
2525
export class ChannelRef {
26-
private readonly channel: Channel;
26+
private readonly channel: grpc.ChannelInterface;
2727
private readonly channelId: number;
2828
private affinityCount: number;
2929
private activeStreamsCount: number;
@@ -35,11 +35,8 @@ export class ChannelRef {
3535
* @param activeStreamsCount Initial streams count.
3636
*/
3737
constructor(
38-
channel: Channel,
39-
channelId: number,
40-
affinityCount?: number,
41-
activeStreamsCount?: number
42-
) {
38+
channel: grpc.ChannelInterface, channelId: number, affinityCount?: number,
39+
activeStreamsCount?: number) {
4340
this.channel = channel;
4441
this.channelId = channelId;
4542
this.affinityCount = affinityCount ? affinityCount : 0;

0 commit comments

Comments
 (0)