Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 1x 118x 118x 1x 117x 1x 1x 1x | const precond = require('precond')
const humanInterval = require('human-interval')
/**
* @class
* @classdesc An abstract class, defining the skeleton for a health
* check strategy
*/
class HealthStrategy {
/**
* @param {String} [timeout] The service becomes unhealthy if it does not
* respond within this period
*/
constructor (timeout = '1 second') {
precond.checkIsNumber(
humanInterval(timeout),
'An invalid format was used for Ping Interval, check human-interval for examples'
)
if (new.target === HealthStrategy) {
throw new TypeError('HealthStrategy cannot be constructed directly')
}
this.timeout = timeout
}
/**
* Check whether a service is healthy
* @abstract
*/
check () {
throw new Error('check() must be implemented by a subclass')
}
/**
* Any cleanup operation that may need to be done when a service
* is destroyed
* @abstract
*/
cleanup () {
throw new Error('clenup() must be implemented by a subclass')
}
}
module.exports = HealthStrategy
|