Skip to content

Commit

Permalink
Merge pull request #67 from murgatroid99/grpc-js_support
Browse files Browse the repository at this point in the history
Rework library to be compatible with grpc-js
  • Loading branch information
WeiranFang committed Apr 3, 2020
2 parents 1e40c4d + 031aaf0 commit 8542f7e
Show file tree
Hide file tree
Showing 9 changed files with 1,207 additions and 1,261 deletions.
4 changes: 3 additions & 1 deletion grpc-gcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ First, Create a json file defining API configuration, with ChannelPoolConfig and
Load configuration to ApiConfig.

```javascript
var grpcGcp = require('grpc-gcp');
// @grpc/grpc-js can be used in place of grpc with no changes
var grpc = require('grpc');
var grpcGcp = require('grpc-gcp')(grpc);
var fs = require('fs');

var apiDefinition = JSON.parse(fs.readFileSync('your_api_config_json_file'));
Expand Down
10 changes: 5 additions & 5 deletions grpc-gcp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grpc-gcp",
"version": "0.2.0",
"version": "0.3.0",
"description": "Extension for supporting Google Cloud Platform specific features for gRPC.",
"main": "build/src/index.js",
"scripts": {
Expand Down Expand Up @@ -35,8 +35,7 @@
"node": ">=6"
},
"dependencies": {
"grpc": "^1.16.0",
"protobufjs": "^6.8.8"
"@grpc/grpc-js": "^0.7.3"
},
"devDependencies": {
"@grpc/proto-loader": "0.4.0",
Expand All @@ -45,9 +44,10 @@
"eslint-plugin-node": "8.0.0",
"eslint-plugin-prettier": "3.0.0",
"google-auth-library": "3.1.1",
"google-gax": "0.25.5",
"google-gax": "^1.15.1",
"google-protobuf": "3.7.0",
"grpc-tools": "1.7.1",
"grpc": "^1.24.2",
"grpc-tools": "^1.8.1",
"gts": "0.9.0",
"mocha": "6.0.2",
"nyc": "13.3.0",
Expand Down
11 changes: 4 additions & 7 deletions grpc-gcp/src/channel_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*
*/

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

/**
* A wrapper of real grpc channel. Also provides helper functions to
* calculate affinity counts and active streams count.
*/
export class ChannelRef {
private readonly channel: Channel;
private readonly channel: grpc.ChannelInterface;
private readonly channelId: number;
private affinityCount: number;
private activeStreamsCount: number;
Expand All @@ -35,11 +35,8 @@ export class ChannelRef {
* @param activeStreamsCount Initial streams count.
*/
constructor(
channel: Channel,
channelId: number,
affinityCount?: number,
activeStreamsCount?: number
) {
channel: grpc.ChannelInterface, channelId: number, affinityCount?: number,
activeStreamsCount?: number) {
this.channel = channel;
this.channelId = channelId;
this.affinityCount = affinityCount ? affinityCount : 0;
Expand Down

0 comments on commit 8542f7e

Please sign in to comment.