Skip to content

Commit 5ac5674

Browse files
Revert "* fix: changed name of WTP_LS_ALLOW_REGEX to WTP_LS_ALLOWED_LOCATIONS_REGEX and introduced a new option WTP_LS_ENABLED (#101)"
This reverts commit cf52ab2.
1 parent cf52ab2 commit 5ac5674

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

config/default.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ const conf = {
3737
},
3838
timeout: process.env.WTP_TIMEOUT || 30000,
3939
"locationSelector": {
40-
"enabled": process.env.WTP_LS_ENABLED || false,
41-
"allowedLocationsRegex": process.env.WTP_LS_ALLOWED_LOCATIONS_REGEX || '_US_',
40+
"allowRegex": process.env.WTP_LS_ALLOW_REGEX || '_US_',
4241
"cacheTtl": process.env.WTP_LS_CACHE_TTL || 10,
4342
"updateTimeout": process.env.WTP_LS_UPDATE_TIMEOUT || 20,
4443
"defaultLocation": process.env.WTP_LS_DEFAULT_LOCATION || "IAD_US_01"

wtp/locationSelector.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ const locationMetrics = {
2929
class LocationSelector {
3030
constructor() {
3131
if (!LocationSelector.instance) {
32-
this.enabled = config.get('wtp.locationSelector.enabled');
3332
this.cachedAllLocations = [];
3433
this.location = config.get('wtp.locationSelector.defaultLocation');
35-
this.allowedLocationsRegex = new RegExp(config.get('wtp.locationSelector.allowedLocationsRegex'));
34+
this.allowRegex = new RegExp(config.get('wtp.locationSelector.allowRegex'));
3635
this.lastUpdated = null;
3736
this.mutex = withTimeout(new Mutex(), config.get('wtp.locationSelector.updateTimeout') * 1000);
3837
LocationSelector.instance = this;
@@ -115,7 +114,7 @@ class LocationSelector {
115114
}
116115

117116
const filtered = Object.keys(newLocations)
118-
.filter(key => this.allowedLocationsRegex.test(key))
117+
.filter(key => this.allowRegex.test(key))
119118
.reduce((arr, key) => {
120119
return [...arr, newLocations[key]];
121120
}, []);
@@ -155,7 +154,7 @@ class LocationSelector {
155154
};
156155

157156
async getLocation() {
158-
if (this.enabled && this.isExpired()) {
157+
if (this.isExpired()) {
159158
try {
160159
await this.mutex.runExclusive(async () => {
161160
if (this.isExpired()) {

0 commit comments

Comments
 (0)