Initial import of verae-fleet from zapier monorepo
This commit is contained in:
commit
3ad95033dc
51 changed files with 3402 additions and 0 deletions
29
src/classify.js
Normal file
29
src/classify.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Row health: operational | degraded | down
|
||||
* @module classify
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* min?: number,
|
||||
* available?: number,
|
||||
* running?: number,
|
||||
* paused?: number,
|
||||
* managed?: boolean,
|
||||
* instances?: Array<{ pid?: number|null, paused?: boolean, healthy?: boolean }>
|
||||
* }} sv
|
||||
* @returns {'operational'|'degraded'|'down'}
|
||||
*/
|
||||
export function classifyService(sv) {
|
||||
const min = sv.min ?? 0;
|
||||
const available = sv.available ?? 0;
|
||||
const running = sv.running ?? 0;
|
||||
const paused = sv.paused ?? 0;
|
||||
const inst = sv.instances || [];
|
||||
const unhealthy = inst.filter((i) => i.pid && i.healthy === false && !i.paused).length;
|
||||
|
||||
if (min === 0 && running === 0) return 'operational';
|
||||
if (available === 0 && min > 0) return 'down';
|
||||
if (available >= min && paused === 0 && unhealthy === 0) return 'operational';
|
||||
return 'degraded';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue