mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-12 17:27:09 +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(){
|
created: function(){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var currentInterval = POLLING_INTERVAL;
|
||||||
var fetch = function(){
|
var fetch = function(){
|
||||||
self.fetchAlertsData().then(function(alerts){
|
self.fetchAlertsData().then(function(alerts){
|
||||||
|
if(self.alerts.toString() == alerts.toString()) {
|
||||||
|
currentInterval *= 1.1;
|
||||||
|
} else {
|
||||||
|
currentInterval = POLLING_INTERVAL;
|
||||||
|
}
|
||||||
self.alerts = alerts;
|
self.alerts = alerts;
|
||||||
|
setTimeout(fetch, currentInterval);
|
||||||
})["catch"](function(xhr){
|
})["catch"](function(xhr){
|
||||||
if(xhr.status === 401) {
|
if(xhr.status === 401) {
|
||||||
clearInterval(timer); // signed out
|
// signed out
|
||||||
}
|
}
|
||||||
if(xhr.status === 0) {
|
if(xhr.status === 0) {
|
||||||
clearInterval(timer); // server unreachable (maybe down)
|
// server unreachable (maybe down)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
fetch();
|
fetch();
|
||||||
var timer = setInterval(fetch, POLLING_INTERVAL);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
Loading…
Reference in New Issue
Block a user