From b44f5669452576c224ee3774a6dfaf7676c3ce9d Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Sat, 8 Jun 2019 12:40:03 -0700 Subject: [PATCH] feat: support apiEndpoint override (#647) --- src/v1/publisher_client.js | 14 +++++++++- src/v1/publisher_client_config.json | 2 +- src/v1/subscriber_client.js | 14 +++++++++- synth.metadata | 10 +++---- test/gapic-v1.js | 42 +++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) diff --git a/src/v1/publisher_client.js b/src/v1/publisher_client.js index 450985032..02e2c1065 100644 --- a/src/v1/publisher_client.js +++ b/src/v1/publisher_client.js @@ -57,14 +57,18 @@ class PublisherClient { * API remote host. */ constructor(opts) { + opts = opts || {}; this._descriptors = {}; + const servicePath = + opts.servicePath || opts.apiEndpoint || this.constructor.servicePath; + // Ensure that options include the service address and port. opts = Object.assign( { clientConfig: {}, port: this.constructor.port, - servicePath: this.constructor.servicePath, + servicePath, }, opts ); @@ -245,6 +249,14 @@ class PublisherClient { return 'pubsub.googleapis.com'; } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'pubsub.googleapis.com'; + } + /** * The port for this API service. */ diff --git a/src/v1/publisher_client_config.json b/src/v1/publisher_client_config.json index 07b6522cd..b1ec0bb46 100644 --- a/src/v1/publisher_client_config.json +++ b/src/v1/publisher_client_config.json @@ -35,7 +35,7 @@ "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 12000, + "initial_rpc_timeout_millis": 25000, "rpc_timeout_multiplier": 1.0, "max_rpc_timeout_millis": 30000, "total_timeout_millis": 600000 diff --git a/src/v1/subscriber_client.js b/src/v1/subscriber_client.js index 5e27c55f6..716172541 100644 --- a/src/v1/subscriber_client.js +++ b/src/v1/subscriber_client.js @@ -57,14 +57,18 @@ class SubscriberClient { * API remote host. */ constructor(opts) { + opts = opts || {}; this._descriptors = {}; + const servicePath = + opts.servicePath || opts.apiEndpoint || this.constructor.servicePath; + // Ensure that options include the service address and port. opts = Object.assign( { clientConfig: {}, port: this.constructor.port, - servicePath: this.constructor.servicePath, + servicePath, }, opts ); @@ -242,6 +246,14 @@ class SubscriberClient { return 'pubsub.googleapis.com'; } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'pubsub.googleapis.com'; + } + /** * The port for this API service. */ diff --git a/synth.metadata b/synth.metadata index 107d2a1df..febca94e4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-06-05T14:48:21.972507Z", + "updateTime": "2019-06-08T11:18:37.058486Z", "sources": [ { "generator": { "name": "artman", - "version": "0.23.1", - "dockerImage": "googleapis/artman@sha256:9d5cae1454da64ac3a87028f8ef486b04889e351c83bb95e83b8fab3959faed0" + "version": "0.24.0", + "dockerImage": "googleapis/artman@sha256:ce425884865f57f18307e597bca1a74a3619b7098688d4995261f3ffb3488681" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b", - "internalRef": "251635729" + "sha": "a12347ec47a7f3d18e35f2effc4295c0b0983213", + "internalRef": "252108410" } }, { diff --git a/test/gapic-v1.js b/test/gapic-v1.js index 930154442..539a4d05f 100644 --- a/test/gapic-v1.js +++ b/test/gapic-v1.js @@ -24,6 +24,27 @@ const error = new Error(); error.code = FAKE_STATUS_CODE; describe('PublisherClient', () => { + it('has servicePath', () => { + const servicePath = pubsubModule.v1.PublisherClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = pubsubModule.v1.PublisherClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = pubsubModule.v1.PublisherClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new pubsubModule.v1.PublisherClient(); + assert(client); + }); + describe('createTopic', () => { it('invokes createTopic without error', done => { const client = new pubsubModule.v1.PublisherClient({ @@ -656,6 +677,27 @@ describe('PublisherClient', () => { }); }); describe('SubscriberClient', () => { + it('has servicePath', () => { + const servicePath = pubsubModule.v1.SubscriberClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = pubsubModule.v1.SubscriberClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = pubsubModule.v1.SubscriberClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new pubsubModule.v1.SubscriberClient(); + assert(client); + }); + describe('createSubscription', () => { it('invokes createSubscription without error', done => { const client = new pubsubModule.v1.SubscriberClient({