Skip to content

Commit

Permalink
fix(config): Remove default timeout and retry values
Browse files Browse the repository at this point in the history
The `pelias.json` schema validation in the API has been setting default
values for the `timeout` and `retries` parameters used for network calls
to each of the other Pelias services.

Years ago, in pelias/microservice-wrapper#30, we
determined that the original defaults of 250ms were too low.

However, the schema defaults were still using this 250ms value, which
means they were effectively overriding the new, more sensible default of
1000ms in the microservice-wrapper library.

This change removes the defaults for both the `timeout` and `retries`
values from the Pelias API, meaning the defaults set in the
`microservice-wrapper` itself will be used.
  • Loading branch information
orangejulius committed Mar 13, 2021
1 parent 44fed98 commit dcae46d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ module.exports = Joi.object().keys({
services: Joi.object().keys({
pip: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }).required(),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
timeout: Joi.number().integer().optional().min(0),
retries: Joi.number().integer().optional().min(0),
}).unknown(false),
placeholder: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }).required(),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
timeout: Joi.number().integer().optional().min(0),
retries: Joi.number().integer().optional().min(0),
}).unknown(false),
interpolation: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }).required(),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
timeout: Joi.number().integer().optional().min(0),
retries: Joi.number().integer().optional().min(0),
}).unknown(false),
libpostal: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }).required(),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
timeout: Joi.number().integer().optional().min(0),
retries: Joi.number().integer().optional().min(0),
}).unknown(false)
}).unknown(false).default({}), // default api.services to an empty object
defaultParameters: Joi.object().keys({
Expand Down
6 changes: 3 additions & 3 deletions test/unit/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ module.exports.tests.service_validation = (test, common) => {
// these tests apply for all the individual service definitions
const services = ['pip', 'placeholder', 'interpolation', 'libpostal'];

test('timeout and retries not specified should default to 250 and 3', (t) => {
test('timeout and retries not specified should default to unset', (t) => {
services.forEach(service => {
const config = {
api: {
Expand All @@ -566,8 +566,8 @@ module.exports.tests.service_validation = (test, common) => {

const result = schema.validate(config);

t.equals(result.value.api.services[service].timeout, 250);
t.equals(result.value.api.services[service].retries, 3);
t.equals(result.value.api.services[service].timeout, undefined);
t.equals(result.value.api.services[service].retries, undefined);

});

Expand Down

0 comments on commit dcae46d

Please sign in to comment.