Skip to content

Commit

Permalink
feat: support apiEndpoint override (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jun 8, 2019
1 parent 9e8f245 commit b44f566
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
14 changes: 13 additions & 1 deletion src/v1/publisher_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/v1/publisher_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/v1/subscriber_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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.
*/
Expand Down
10 changes: 5 additions & 5 deletions synth.metadata
Original file line number Diff line number Diff line change
@@ -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"
}
},
{
Expand Down
42 changes: 42 additions & 0 deletions test/gapic-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit b44f566

Please sign in to comment.