Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feat: allow pollIntervalMs to be configured #392

Merged
merged 2 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"predocs-test": "npm run docs"
},
"dependencies": {
"@google-cloud/common": "^2.0.0",
"@google-cloud/common": "^2.3.0",
"@google-cloud/paginator": "^2.0.0",
"@google-cloud/projectify": "^1.0.0",
"@google-cloud/promisify": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class Address extends common.ServiceObject {
id: name,
createMethod: region.createAddress.bind(region),
methods: methods,
pollIntervalMs: region.compute.pollIntervalMs,
});
/**
* @name Address#name
Expand Down
1 change: 1 addition & 0 deletions src/autoscaler.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Autoscaler extends common.ServiceObject {
id: name,
createMethod: zone.createAutoscaler.bind(zone),
methods: methods,
pollIntervalMs: zone.compute.pollIntervalMs,
});
/**
* @name Autoscaler#name
Expand Down
1 change: 1 addition & 0 deletions src/disk.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Disk extends common.ServiceObject {
id: name,
createMethod: zone.createDisk.bind(zone),
methods: methods,
pollIntervalMs: zone.compute.pollIntervalMs,
});
/**
* @name Disk#name
Expand Down
1 change: 1 addition & 0 deletions src/firewall.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class Firewall extends common.ServiceObject {
id: name,
createMethod: compute.createFirewall.bind(compute),
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
/**
* The parent {@link Compute} instance of this {@link Firewall} instance.
Expand Down
1 change: 1 addition & 0 deletions src/health-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class HealthCheck extends common.ServiceObject {
compute.createHealthCheck(name, options, callback);
},
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
/**
* The parent {@link Compute} instance of this {@link HealthCheck} instance.
Expand Down
1 change: 1 addition & 0 deletions src/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class Image extends common.ServiceObject {
id: name,
createMethod: compute.createImage.bind(compute),
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
}
/**
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const Image = require('./image.js');
* We will exponentially backoff subsequent requests by default.
* @property {number} [maxRetries=3] Maximum number of automatic retries
* attempted before returning the error.
* @property {number} [pollIntervalMs=500] Poll interval for long running
* operations.
* @property {Constructor} [promise] Custom promise module to use instead of
* native Promises.
* @property {string} [apiEndpoint] The API endpoint of the service used to make requests. Defaults to `compute.googleapis.com`
Expand Down Expand Up @@ -88,6 +90,7 @@ class Compute extends common.Service {
packageJson: require('../package.json'),
};
super(config, options);
this.pollIntervalMs = options.pollIntervalMs;
}
/**
* Create a firewall.
Expand Down
1 change: 1 addition & 0 deletions src/instance-group-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class InstanceGroupManager extends common.ServiceObject {
id: name,
// createMethod: zone.createInstanceGroupManager.bind(zone),
methods: methods,
pollIntervalMs: zone.compute.pollIntervalMs,
});
/**
* The parent {@link Zone} instance of this {@link InstanceGroup} instance.
Expand Down
1 change: 1 addition & 0 deletions src/instance-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class InstanceGroup extends common.ServiceObject {
id: name,
createMethod: zone.createInstanceGroup.bind(zone),
methods: methods,
pollIntervalMs: zone.compute.pollIntervalMs,
});
/**
* The parent {@link Zone} instance of this {@link InstanceGroup} instance.
Expand Down
1 change: 1 addition & 0 deletions src/machine-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MachineType extends common.ServiceObject {
*/
id: name,
methods: methods,
pollIntervalMs: zone.compute.pollIntervalMs,
});
/**
* The parent {@link Zone} instance of this {@link MachineType} instance.
Expand Down
1 change: 1 addition & 0 deletions src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class Network extends common.ServiceObject {
id: name,
createMethod: compute.createNetwork.bind(compute),
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
/**
* The parent {@link Compute} instance of this {@link Network} instance.
Expand Down
3 changes: 3 additions & 0 deletions src/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class Operation extends common.Operation {
*/
id: name,
methods: methods,
pollIntervalMs: isCompute
? scope.pollIntervalMs
: scope.compute.pollIntervalMs,
});

/**
Expand Down
1 change: 1 addition & 0 deletions src/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Project extends common.ServiceObject {
baseUrl: '',
id: '',
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ class Region extends common.ServiceObject {
*/
id: name,
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
/**
* @name Region#name
* @type {string}
*/
this.name = name;
this.compute = compute;
this.interceptors.push({
request: function(reqOpts) {
if (reqOpts.uri.indexOf('/global/forwardingRules') > -1) {
Expand Down
3 changes: 3 additions & 0 deletions src/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ class Rule extends common.ServiceObject {
id: name,
createMethod: scope.createRule.bind(scope),
methods: methods,
pollIntervalMs: scope.compute
? scope.compute.pollIntervalMs
: scope.pollIntervalMs,
});
/**
* @name Rule#scope
Expand Down
1 change: 1 addition & 0 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Service extends common.ServiceObject {
id: name,
createMethod: compute.createService.bind(compute),
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
/**
* The parent {@link Compute} instance of this {@link Service} instance.
Expand Down
1 change: 1 addition & 0 deletions src/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Snapshot extends common.ServiceObject {
*/
id: name,
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
};
if (isDisk) {
config.createMethod = scope.createSnapshot.bind(scope);
Expand Down
1 change: 1 addition & 0 deletions src/subnetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class Subnetwork extends common.ServiceObject {
id: name,
createMethod: region.createSubnetwork.bind(region),
methods: methods,
pollIntervalMs: region.compute.pollIntervalMs,
});
/**
* @name Subnetwork#name
Expand Down
1 change: 1 addition & 0 deletions src/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class VM extends common.ServiceObject {
id: name,
createMethod: zone.createVM.bind(zone),
methods: methods,
pollIntervalMs: zone.compute.pollIntervalMs,
});

/**
Expand Down
1 change: 1 addition & 0 deletions src/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class Zone extends common.ServiceObject {
*/
id: name,
methods: methods,
pollIntervalMs: compute.pollIntervalMs,
});
/**
* The parent {@link Compute} instance of this {@link Zone} instance.
Expand Down
1 change: 1 addition & 0 deletions test/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Address', function() {
const ADDRESS_NAME = 'us-central1';
const REGION = {
createAddress: () => {},
compute: {},
};

before(function() {
Expand Down
4 changes: 3 additions & 1 deletion test/instance-group-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ describe('InstanceGroupManager', function() {

const staticMethods = {};

const ZONE = {};
const ZONE = {
compute: {},
};
const NAME = 'instance-group-manager-name';

before(function() {
Expand Down
1 change: 1 addition & 0 deletions test/instance-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('InstanceGroup', function() {
const ZONE = {
createInstanceGroup: util.noop,
vm: util.noop,
compute: {},
};
const NAME = 'instance-group-name';

Expand Down
1 change: 1 addition & 0 deletions test/machine-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('MachineType', function() {
const ZONE_NAME = 'zone-1';
const ZONE = {
name: ZONE_NAME,
compute: {},
};

const MACHINE_TYPE_NAME = 'g1-small';
Expand Down
1 change: 1 addition & 0 deletions test/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Operation', function() {

const SCOPE = {
Promise: Promise,
compute: {},
};
const OPERATION_NAME = 'operation-name';

Expand Down
1 change: 1 addition & 0 deletions test/subnetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('Subnetwork', function() {
const REGION = {
createSubnetwork: util.noop,
name: REGION_NAME,
compute: {},
};

before(function() {
Expand Down