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