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}.`; 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); const blob = this.parseTemplate(this.params.templates[channel] || this.params.templates["default"], context);
this.axios({ this.axios({
url: url, url: url,
method: "POST", method: "POST",
@@ -78,7 +79,7 @@ export default class ReportHTTP extends Report {
level: 'error', level: 'error',
message: error message: error
}); });
}) });
}; };
report = (channel, content) => { report = (channel, content) => {

View File

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