Skip to content

Commit 7484ea4

Browse files
stephenpluspluscallmehiphop
authored andcommitted
logging: incorporate @google-cloud/common-grpc (#1949)
1 parent 731452f commit 7484ea4

9 files changed

Lines changed: 33 additions & 19 deletions

File tree

handwritten/logging/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"stackdriver"
5353
],
5454
"dependencies": {
55-
"@google-cloud/common": "^0.11.0",
55+
"@google-cloud/common": "^0.12.0",
56+
"@google-cloud/common-grpc": "^0.1.1",
5657
"arrify": "^1.0.0",
5758
"async": "^2.1.4",
5859
"extend": "^3.0.0",

handwritten/logging/src/entry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
'use strict';
2222

23-
var common = require('@google-cloud/common');
23+
var commonGrpc = require('@google-cloud/common-grpc');
2424
var extend = require('extend');
2525
var is = require('is');
2626
var isCircular = require('is-circular');
@@ -103,7 +103,7 @@ Entry.fromApiResponse_ = function(entry) {
103103
var data = entry[entry.payload];
104104

105105
if (entry.payload === 'jsonPayload') {
106-
data = common.GrpcService.structToObj_(data);
106+
data = commonGrpc.Service.structToObj_(data);
107107
}
108108

109109
var serializedEntry = new Entry(entry, data);
@@ -130,7 +130,7 @@ Entry.prototype.toJSON = function() {
130130
var entry = extend(true, {}, this.metadata);
131131

132132
if (is.object(this.data)) {
133-
entry.jsonPayload = common.GrpcService.objToStruct_(this.data, {
133+
entry.jsonPayload = commonGrpc.Service.objToStruct_(this.data, {
134134
stringify: true
135135
});
136136
} else if (is.string(this.data)) {

handwritten/logging/src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var arrify = require('arrify');
2424
var common = require('@google-cloud/common');
25+
var commonGrpc = require('@google-cloud/common-grpc');
2526
var extend = require('extend');
2627
var format = require('string-format-obj');
2728
var googleProtoFiles = require('google-proto-files');
@@ -80,10 +81,10 @@ function Logging(options) {
8081
packageJson: require('../package.json')
8182
};
8283

83-
common.GrpcService.call(this, config, options);
84+
commonGrpc.Service.call(this, config, options);
8485
}
8586

86-
util.inherits(Logging, common.GrpcService);
87+
util.inherits(Logging, commonGrpc.Service);
8788

8889
// jscs:disable maximumLineLength
8990
/**

handwritten/logging/src/log.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var arrify = require('arrify');
2424
var async = require('async');
2525
var common = require('@google-cloud/common');
26+
var commonGrpc = require('@google-cloud/common-grpc');
2627
var extend = require('extend');
2728
var is = require('is');
2829
var util = require('util');
@@ -98,14 +99,14 @@ function Log(logging, name) {
9899
}
99100
};
100101

101-
common.GrpcServiceObject.call(this, {
102+
commonGrpc.ServiceObject.call(this, {
102103
parent: logging,
103104
id: this.name,
104105
methods: methods
105106
});
106107
}
107108

108-
util.inherits(Log, common.GrpcServiceObject);
109+
util.inherits(Log, commonGrpc.ServiceObject);
109110

110111
/**
111112
* Return an array of log entries with the desired severity assigned.

handwritten/logging/src/sink.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'use strict';
2222

2323
var common = require('@google-cloud/common');
24+
var commonGrpc = require('@google-cloud/common-grpc');
2425
var extend = require('extend');
2526
var util = require('util');
2627

@@ -146,7 +147,7 @@ function Sink(logging, name) {
146147
}
147148
};
148149

149-
common.GrpcServiceObject.call(this, {
150+
commonGrpc.ServiceObject.call(this, {
150151
parent: logging,
151152
baseUrl: '/sinks',
152153
id: name,
@@ -155,7 +156,7 @@ function Sink(logging, name) {
155156
});
156157
}
157158

158-
util.inherits(Sink, common.GrpcServiceObject);
159+
util.inherits(Sink, commonGrpc.ServiceObject);
159160

160161
/**
161162
* Set the sink's filter.

handwritten/logging/test/entry.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var assert = require('assert');
2020
var extend = require('extend');
2121
var GrpcService = require('@google-cloud/common').GrpcService;
2222
var proxyquire = require('proxyquire');
23+
var util = require('@google-cloud/common').util;
2324

2425
function FakeGrpcService() {}
2526

@@ -32,8 +33,8 @@ describe('Entry', function() {
3233

3334
before(function() {
3435
Entry = proxyquire('../src/entry.js', {
35-
'@google-cloud/common': {
36-
GrpcService: FakeGrpcService
36+
'@google-cloud/common-grpc': {
37+
Service: FakeGrpcService
3738
}
3839
});
3940
});
@@ -132,6 +133,10 @@ describe('Entry', function() {
132133
});
133134

134135
describe('toJSON', function() {
136+
beforeEach(function() {
137+
FakeGrpcService.objToStruct_ = util.noop;
138+
});
139+
135140
it('should not modify the original instance', function() {
136141
var entryBefore = extend(true, {}, entry);
137142
entry.toJSON();

handwritten/logging/test/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ describe('Logging', function() {
9191
before(function() {
9292
Logging = proxyquire('../', {
9393
'@google-cloud/common': {
94-
GrpcService: FakeGrpcService,
9594
paginator: fakePaginator,
9695
util: fakeUtil
9796
},
97+
'@google-cloud/common-grpc': {
98+
Service: FakeGrpcService
99+
},
98100
'./log.js': FakeLog,
99101
'./entry.js': FakeEntry,
100102
'./sink.js': FakeSink

handwritten/logging/test/log.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ describe('Log', function() {
7070

7171
before(function() {
7272
Log = proxyquire('../src/log.js', {
73-
'./entry.js': Entry,
74-
'./metadata.js': FakeMetadata,
7573
'@google-cloud/common': {
76-
GrpcServiceObject: FakeGrpcServiceObject,
7774
util: fakeUtil
78-
}
75+
},
76+
'@google-cloud/common-grpc': {
77+
ServiceObject: FakeGrpcServiceObject,
78+
},
79+
'./entry.js': Entry,
80+
'./metadata.js': FakeMetadata
7981
});
8082
var assignSeverityToEntries_ = Log.assignSeverityToEntries_;
8183
Log.assignSeverityToEntries_ = function() {

handwritten/logging/test/sink.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ var fakeUtil = extend({}, util, {
3030
}
3131
});
3232

33-
3433
function FakeGrpcServiceObject() {
3534
this.calledWith_ = arguments;
3635
}
@@ -48,8 +47,10 @@ describe('Sink', function() {
4847
before(function() {
4948
Sink = proxyquire('../src/sink.js', {
5049
'@google-cloud/common': {
51-
GrpcServiceObject: FakeGrpcServiceObject,
5250
util: fakeUtil
51+
},
52+
'@google-cloud/common-grpc': {
53+
ServiceObject: FakeGrpcServiceObject,
5354
}
5455
});
5556
});

0 commit comments

Comments
 (0)