1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

improved axios retry

This commit is contained in:
Massimo Candela
2020-11-21 05:58:58 +01:00
parent 95c8b624e4
commit ffbb33c6fc
2 changed files with 11 additions and 8 deletions

View File

@@ -67,6 +67,7 @@ export default class ReportHTTP extends Report {
context.summary = `${context.summary}. Top ${context.pathNumber} most used AS paths: ${context.paths}.`;
}
const blob = this.parseTemplate(this.params.templates[channel] || this.params.templates["default"], context);
this.axios({
url: url,
method: "POST",
@@ -78,7 +79,7 @@ export default class ReportHTTP extends Report {
level: 'error',
message: error
});
})
});
};
report = (channel, content) => {

View File

@@ -14,7 +14,7 @@ const retry = function (axios, error) {
} else {
reject(error);
}
}, 10000);
}, 2000);
});
}
@@ -33,12 +33,14 @@ export default function(axios, httpsAgent, userAgent) {
}
// Retry
axios.interceptors.response.use(null, (error) => {
if (error.config) {
return retry(axios, error);
}
return Promise.reject(error);
});
axios.interceptors.response.use(
response => response,
error => {
if (error.config) {
return retry(axios, error);
}
return Promise.reject(error);
});
return axios;
}