mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
chore: update the healthchecks and HealthCheck
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { cooldownTrigger } from "./cooldownTrigger"
|
||||
import { changeOnFirstSuccess } from "./changeOnFirstSuccess"
|
||||
import { successFailure } from "./successFailure"
|
||||
|
||||
export const defaultTrigger = changeOnFirstSuccess({
|
||||
beforeFirstSuccess: cooldownTrigger(0),
|
||||
afterFirstSuccess: cooldownTrigger(30000),
|
||||
export const defaultTrigger = successFailure({
|
||||
duringSuccess: cooldownTrigger(0),
|
||||
duringError: cooldownTrigger(30000),
|
||||
})
|
||||
|
||||
32
lib/trigger/successFailure.ts
Normal file
32
lib/trigger/successFailure.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Trigger } from "."
|
||||
|
||||
export function successFailure(o: {
|
||||
duringSuccess: Trigger
|
||||
duringError: Trigger
|
||||
}): Trigger {
|
||||
return async function* (getInput) {
|
||||
while (true) {
|
||||
const beforeSuccess = o.duringSuccess(getInput)
|
||||
yield
|
||||
let currentValue = getInput()
|
||||
beforeSuccess.next()
|
||||
for (
|
||||
let res = await beforeSuccess.next();
|
||||
currentValue?.lastResult !== "passing" && !res.done;
|
||||
res = await beforeSuccess.next()
|
||||
) {
|
||||
yield
|
||||
currentValue = getInput()
|
||||
}
|
||||
const duringError = o.duringError(getInput)
|
||||
for (
|
||||
let res = await duringError.next();
|
||||
currentValue?.lastResult === "passing" && !res.done;
|
||||
res = await duringError.next()
|
||||
) {
|
||||
yield
|
||||
currentValue = getInput()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user