Skip to content

Commit

Permalink
pubsub: incorporate @google-cloud/common-grpc (#1950)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus authored and callmehiphop committed Jan 31, 2017
1 parent 27eb176 commit a633ab8
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 18 deletions.
3 changes: 2 additions & 1 deletion packages/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"pubsub"
],
"dependencies": {
"@google-cloud/common": "^0.11.0",
"@google-cloud/common": "^0.12.0",
"@google-cloud/common-grpc": "^0.1.1",
"arrify": "^1.0.0",
"extend": "^3.0.0",
"google-gax": "^0.10.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/pubsub/src/iam.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var arrify = require('arrify');
var common = require('@google-cloud/common');
var commonGrpc = require('@google-cloud/common-grpc');
var is = require('is');
var util = require('util');

Expand Down Expand Up @@ -79,10 +80,10 @@ function IAM(pubsub, id) {

this.id = id;

common.GrpcService.call(this, config, pubsub.options);
commonGrpc.Service.call(this, config, pubsub.options);
}

util.inherits(IAM, common.GrpcService);
util.inherits(IAM, commonGrpc.Service);

/**
* Get the IAM policy
Expand Down
5 changes: 3 additions & 2 deletions packages/pubsub/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var arrify = require('arrify');
var common = require('@google-cloud/common');
var commonGrpc = require('@google-cloud/common-grpc');
var extend = require('extend');
var is = require('is');
var util = require('util');
Expand Down Expand Up @@ -76,10 +77,10 @@ function PubSub(options) {

this.options = options;

common.GrpcService.call(this, config, options);
commonGrpc.Service.call(this, config, options);
}

util.inherits(PubSub, common.GrpcService);
util.inherits(PubSub, commonGrpc.Service);

/**
* Create a topic with the given name.
Expand Down
5 changes: 3 additions & 2 deletions packages/pubsub/src/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var arrify = require('arrify');
var common = require('@google-cloud/common');
var commonGrpc = require('@google-cloud/common-grpc');
var events = require('events');
var is = require('is');
var modelo = require('modelo');
Expand Down Expand Up @@ -270,7 +271,7 @@ function Subscription(pubsub, options) {
config.methods.create = true;
}

common.GrpcServiceObject.call(this, config);
commonGrpc.ServiceObject.call(this, config);
events.EventEmitter.call(this);

this.autoAck = is.boolean(options.autoAck) ? options.autoAck : false;
Expand Down Expand Up @@ -331,7 +332,7 @@ function Subscription(pubsub, options) {
this.listenForEvents_();
}

modelo.inherits(Subscription, common.GrpcServiceObject, events.EventEmitter);
modelo.inherits(Subscription, commonGrpc.ServiceObject, events.EventEmitter);

/**
* Simplify a message from an API response to have five properties: `id`,
Expand Down
5 changes: 3 additions & 2 deletions packages/pubsub/src/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var arrify = require('arrify');
var common = require('@google-cloud/common');
var commonGrpc = require('@google-cloud/common-grpc');
var extend = require('extend');
var is = require('is');
var util = require('util');
Expand Down Expand Up @@ -180,7 +181,7 @@ function Topic(pubsub, name) {
}
};

common.GrpcServiceObject.call(this, {
commonGrpc.ServiceObject.call(this, {
parent: pubsub,
id: this.name,
createMethod: pubsub.createTopic.bind(pubsub),
Expand Down Expand Up @@ -224,7 +225,7 @@ function Topic(pubsub, name) {
this.iam = new IAM(pubsub, this.name);
}

util.inherits(Topic, common.GrpcServiceObject);
util.inherits(Topic, commonGrpc.ServiceObject);

/**
* Format a message object as the upstream API expects it.
Expand Down
6 changes: 4 additions & 2 deletions packages/pubsub/test/iam.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var assert = require('assert');
var extend = require('extend');
var GrpcService = require('@google-cloud/common').GrpcService;
var GrpcService = require('@google-cloud/common-grpc').Service;
var nodeutil = require('util');
var proxyquire = require('proxyquire');
var util = require('@google-cloud/common').util;
Expand Down Expand Up @@ -52,8 +52,10 @@ describe('IAM', function() {
before(function() {
IAM = proxyquire('../src/iam.js', {
'@google-cloud/common': {
GrpcService: FakeGrpcService,
util: fakeUtil
},
'@google-cloud/common-grpc': {
Service: FakeGrpcService
}
});
});
Expand Down
4 changes: 3 additions & 1 deletion packages/pubsub/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ describe('PubSub', function() {
delete process.env.PUBSUB_EMULATOR_HOST;
PubSub = proxyquire('../', {
'@google-cloud/common': {
GrpcService: FakeGrpcService,
paginator: fakePaginator,
util: fakeUtil
},
'@google-cloud/common-grpc': {
Service: FakeGrpcService
},
'./subscription.js': Subscription,
'./topic.js': Topic
});
Expand Down
6 changes: 4 additions & 2 deletions packages/pubsub/test/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var assert = require('assert');
var extend = require('extend');
var GrpcServiceObject = require('@google-cloud/common').GrpcServiceObject;
var GrpcServiceObject = require('@google-cloud/common-grpc').ServiceObject;
var nodeutil = require('util');
var proxyquire = require('proxyquire');
var util = require('@google-cloud/common').util;
Expand Down Expand Up @@ -81,9 +81,11 @@ describe('Subscription', function() {
before(function() {
Subscription = proxyquire('../src/subscription.js', {
'@google-cloud/common': {
GrpcServiceObject: FakeGrpcServiceObject,
util: fakeUtil
},
'@google-cloud/common-grpc': {
ServiceObject: FakeGrpcServiceObject
},
'./iam.js': FakeIAM
});

Expand Down
10 changes: 6 additions & 4 deletions packages/pubsub/test/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var assert = require('assert');
var extend = require('extend');
var GrpcServiceObject = require('@google-cloud/common').GrpcServiceObject;
var GrpcServiceObject = require('@google-cloud/common-grpc').ServiceObject;
var nodeutil = require('util');
var proxyquire = require('proxyquire');
var util = require('@google-cloud/common').util;
Expand Down Expand Up @@ -60,11 +60,13 @@ describe('Topic', function() {

before(function() {
Topic = proxyquire('../src/topic.js', {
'./iam.js': FakeIAM,
'@google-cloud/common': {
GrpcServiceObject: FakeGrpcServiceObject,
util: fakeUtil
}
},
'@google-cloud/common-grpc': {
ServiceObject: FakeGrpcServiceObject
},
'./iam.js': FakeIAM
});
});

Expand Down

0 comments on commit a633ab8

Please sign in to comment.