Skip to content

Commit b44f566

Browse files
yoshi-automationJustinBeckwith
authored andcommitted
feat: support apiEndpoint override (#647)
1 parent 9e8f245 commit b44f566

File tree

5 files changed

+74
-8
lines changed

5 files changed

+74
-8
lines changed

src/v1/publisher_client.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ class PublisherClient {
5757
* API remote host.
5858
*/
5959
constructor(opts) {
60+
opts = opts || {};
6061
this._descriptors = {};
6162

63+
const servicePath =
64+
opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;
65+
6266
// Ensure that options include the service address and port.
6367
opts = Object.assign(
6468
{
6569
clientConfig: {},
6670
port: this.constructor.port,
67-
servicePath: this.constructor.servicePath,
71+
servicePath,
6872
},
6973
opts
7074
);
@@ -245,6 +249,14 @@ class PublisherClient {
245249
return 'pubsub.googleapis.com';
246250
}
247251

252+
/**
253+
* The DNS address for this API service - same as servicePath(),
254+
* exists for compatibility reasons.
255+
*/
256+
static get apiEndpoint() {
257+
return 'pubsub.googleapis.com';
258+
}
259+
248260
/**
249261
* The port for this API service.
250262
*/

src/v1/publisher_client_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"initial_retry_delay_millis": 100,
3636
"retry_delay_multiplier": 1.3,
3737
"max_retry_delay_millis": 60000,
38-
"initial_rpc_timeout_millis": 12000,
38+
"initial_rpc_timeout_millis": 25000,
3939
"rpc_timeout_multiplier": 1.0,
4040
"max_rpc_timeout_millis": 30000,
4141
"total_timeout_millis": 600000

src/v1/subscriber_client.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ class SubscriberClient {
5757
* API remote host.
5858
*/
5959
constructor(opts) {
60+
opts = opts || {};
6061
this._descriptors = {};
6162

63+
const servicePath =
64+
opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;
65+
6266
// Ensure that options include the service address and port.
6367
opts = Object.assign(
6468
{
6569
clientConfig: {},
6670
port: this.constructor.port,
67-
servicePath: this.constructor.servicePath,
71+
servicePath,
6872
},
6973
opts
7074
);
@@ -242,6 +246,14 @@ class SubscriberClient {
242246
return 'pubsub.googleapis.com';
243247
}
244248

249+
/**
250+
* The DNS address for this API service - same as servicePath(),
251+
* exists for compatibility reasons.
252+
*/
253+
static get apiEndpoint() {
254+
return 'pubsub.googleapis.com';
255+
}
256+
245257
/**
246258
* The port for this API service.
247259
*/

synth.metadata

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"updateTime": "2019-06-05T14:48:21.972507Z",
2+
"updateTime": "2019-06-08T11:18:37.058486Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.23.1",
8-
"dockerImage": "googleapis/artman@sha256:9d5cae1454da64ac3a87028f8ef486b04889e351c83bb95e83b8fab3959faed0"
7+
"version": "0.24.0",
8+
"dockerImage": "googleapis/artman@sha256:ce425884865f57f18307e597bca1a74a3619b7098688d4995261f3ffb3488681"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
16-
"internalRef": "251635729"
15+
"sha": "a12347ec47a7f3d18e35f2effc4295c0b0983213",
16+
"internalRef": "252108410"
1717
}
1818
},
1919
{

test/gapic-v1.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ const error = new Error();
2424
error.code = FAKE_STATUS_CODE;
2525

2626
describe('PublisherClient', () => {
27+
it('has servicePath', () => {
28+
const servicePath = pubsubModule.v1.PublisherClient.servicePath;
29+
assert(servicePath);
30+
});
31+
32+
it('has apiEndpoint', () => {
33+
const apiEndpoint = pubsubModule.v1.PublisherClient.apiEndpoint;
34+
assert(apiEndpoint);
35+
});
36+
37+
it('has port', () => {
38+
const port = pubsubModule.v1.PublisherClient.port;
39+
assert(port);
40+
assert(typeof port === 'number');
41+
});
42+
43+
it('should create a client with no options', () => {
44+
const client = new pubsubModule.v1.PublisherClient();
45+
assert(client);
46+
});
47+
2748
describe('createTopic', () => {
2849
it('invokes createTopic without error', done => {
2950
const client = new pubsubModule.v1.PublisherClient({
@@ -656,6 +677,27 @@ describe('PublisherClient', () => {
656677
});
657678
});
658679
describe('SubscriberClient', () => {
680+
it('has servicePath', () => {
681+
const servicePath = pubsubModule.v1.SubscriberClient.servicePath;
682+
assert(servicePath);
683+
});
684+
685+
it('has apiEndpoint', () => {
686+
const apiEndpoint = pubsubModule.v1.SubscriberClient.apiEndpoint;
687+
assert(apiEndpoint);
688+
});
689+
690+
it('has port', () => {
691+
const port = pubsubModule.v1.SubscriberClient.port;
692+
assert(port);
693+
assert(typeof port === 'number');
694+
});
695+
696+
it('should create a client with no options', () => {
697+
const client = new pubsubModule.v1.SubscriberClient();
698+
assert(client);
699+
});
700+
659701
describe('createSubscription', () => {
660702
it('invokes createSubscription without error', done => {
661703
const client = new pubsubModule.v1.SubscriberClient({

0 commit comments

Comments
 (0)