mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
reconfigured monitor
This commit is contained in:
@@ -6,30 +6,30 @@ import { loadHistoryContents } from "../../caching";
|
||||
|
||||
// prettier-ignore
|
||||
export const loadContents = (cfg = {}) => {
|
||||
const {
|
||||
windowSize,
|
||||
initialInterval = 3 * 1000,
|
||||
maxInterval = 10 * initialInterval,
|
||||
disablePoll = false,
|
||||
const {
|
||||
windowSize,
|
||||
initialInterval = 2 * 1000,
|
||||
maxInterval = 10 * initialInterval,
|
||||
disablePoll = false
|
||||
} = cfg;
|
||||
|
||||
return switchMap(([{id}, params, hid]) => {
|
||||
return switchMap(([{ id }, params, hid]) => {
|
||||
|
||||
// a single history update
|
||||
const singleLoad$ = defer(() => of([id, params, hid]).pipe(
|
||||
loadHistoryContents({ windowSize }),
|
||||
));
|
||||
const singleLoad$ = of([id, params, hid]).pipe(
|
||||
loadHistoryContents({ windowSize })
|
||||
);
|
||||
|
||||
// start repeating, delay gets longer over time until unsubscribed
|
||||
const freshPoll$ = singleLoad$.pipe(
|
||||
const freshPoll$ = defer(() => singleLoad$.pipe(
|
||||
decay({ initialInterval, maxInterval }),
|
||||
repeat(),
|
||||
);
|
||||
repeat()
|
||||
));
|
||||
|
||||
// history, tools routes all refresh
|
||||
// exclude our own polling url though
|
||||
const routes = [/api\/(history|tools|histories)/];
|
||||
const methods = ["POST", "PUT", "DELETE"]
|
||||
const methods = ["POST", "PUT", "DELETE"];
|
||||
const resetPoll$ = monitorXHR({ methods, routes });
|
||||
|
||||
// resets re-subscribe to freshPoll$ starting the decay over again
|
||||
@@ -40,5 +40,5 @@ export const loadContents = (cfg = {}) => {
|
||||
);
|
||||
|
||||
return disablePoll ? singleLoad$ : poll$;
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import { of } from "rxjs";
|
||||
import { mergeMap, delay } from "rxjs/operators";
|
||||
|
||||
let decayCounter = 0;
|
||||
|
||||
// prettier-ignore
|
||||
export const decay = (cfg = {}) => {
|
||||
const {
|
||||
@@ -15,12 +17,13 @@ export const decay = (cfg = {}) => {
|
||||
}
|
||||
|
||||
let counter = 0;
|
||||
decayCounter++;
|
||||
|
||||
return mergeMap(val => {
|
||||
let waitTime = Math.floor(initialInterval * Math.exp(lambda * counter++));
|
||||
waitTime = Math.max(waitTime, initialInterval);
|
||||
waitTime = Math.min(waitTime, maxInterval);
|
||||
// console.log("decay time", waitTime);
|
||||
console.log("decay time", decayCounter, waitTime);
|
||||
return of(val).pipe(delay(waitTime))
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user