import ConnectionHealthData from './ConnectionHealthData' ; import ConnectionHealthPolicy from './ConnectionHealthPolicy' ; import ConnectionHealthPolicyConfiguration from './ConnectionHealthPolicyConfiguration' ; export default class BaseConnectionHealthPolicy implements ConnectionHealthPolicy { protected currentData : ConnectionHealthData ; protected minHealth : number ; protected maxHealth : number ; protected currentHealth : number ; constructor ( configuration , data ) { this . minHealth = configuration . minHealth ; this . maxHealth = configuration . maxHealth ; this . currentHealth = configuration . initialHealth ; this . currentData = data . clone ( ) ; } minimumHealth ( ) { return this . minHealth ; } maximumHealth ( ) { return this . maxHealth ; } health ( ) { return this . maximumHealth ( ) ; } update ( connectionHealthData ) { this . currentData = connectionHealthData ; } getConnectionHealthData ( ) { return this . currentData . clone ( ) ; } healthy ( ) { return this . health ( ) > this . minimumHealth ( ) ; } healthIfChanged ( ) { const newHealth = this . health ( ) ; if ( newHealth !== this . currentHealth ) { this . currentHealth = newHealth ; return newHealth ; } return null ; } }