mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-12 09:17:05 +02:00
Reduce polling access by exponential backoff like strategy
This commit is contained in:
parent
0c940ee666
commit
6e778fe11f
@ -14,20 +14,26 @@
|
||||
|
||||
created: function(){
|
||||
var self = this;
|
||||
var currentInterval = POLLING_INTERVAL;
|
||||
var fetch = function(){
|
||||
self.fetchAlertsData().then(function(alerts){
|
||||
if(self.alerts.toString() == alerts.toString()) {
|
||||
currentInterval *= 1.1;
|
||||
} else {
|
||||
currentInterval = POLLING_INTERVAL;
|
||||
}
|
||||
self.alerts = alerts;
|
||||
setTimeout(fetch, currentInterval);
|
||||
})["catch"](function(xhr){
|
||||
if(xhr.status === 401) {
|
||||
clearInterval(timer); // signed out
|
||||
// signed out
|
||||
}
|
||||
if(xhr.status === 0) {
|
||||
clearInterval(timer); // server unreachable (maybe down)
|
||||
// server unreachable (maybe down)
|
||||
}
|
||||
});
|
||||
};
|
||||
fetch();
|
||||
var timer = setInterval(fetch, POLLING_INTERVAL);
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
Loading…
Reference in New Issue
Block a user