Repository URL to install this package:
|
Version:
1.1.0 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHealthyTarget = void 0;
const cafe_utility_1 = require("cafe-utility");
function getHealthyTarget(targets) {
const healthyIfLastErrorIsBefore = Date.now() - cafe_utility_1.Dates.hours(2);
const healthyTargets = targets.filter(x => x.lastErrorAt < healthyIfLastErrorIsBefore);
return healthyTargets[0] || targets[0];
}
exports.getHealthyTarget = getHealthyTarget;