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:
@@ -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) => {
|
||||
|
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user