import { IClusterDefinition } from '@/typings/typings' ; import { EventEmitter } from 'events' ; export default abstract class BaseDiscoveryProvider extends EventEmitter { private clusterList : IClusterDefinition [ ] = [ ] ; private lastError : Error | undefined ; private environmentList : string [ ] = [ ] ; private regionList : string [ ] = [ ] ; /**
     * Initiates loading of the clusters. Users of this API should listen for the
     * 'loaded-*' events since clusters may be loaded incrementally or on a timer/interval.
     * If clusters fail to load at any point, an 'error' event will be fired. It is the callers
     * responsibility to handle this error appropriately.
     */ public start ( ) { throw new Error ( 'Implementors must implement start()' ) ; } /**
     * Fetches the current list of clusters. Note, clusters could be empty until
     * they are loaded. Clusters are loaded asynchonously. See the 'load'
     * method.
     */ get clusters ( ) : IClusterDefinition [ ] { return this . clusterList ; } param clusters set clusters ( clusters ) { this . clusterList = clusters ; this . emit ( 'loaded-clusters' , this . clusterList ) ; } param err set error ( err ) { this . lastError = err ; if ( err ) { this . emit ( 'error' , this . lastError ) ; } } returns get environments ( ) : string [ ] { return this . environmentList ; } param environments set environments ( environments ) { this . environmentList = environments ; this . emit ( 'loaded-environments' , this . environmentList ) ; } /**
     * Fetches the list of discovered regions.
     */ get regions ( ) : string [ ] { return this . regionList ; } param regions set regions ( regions ) { this . regionList = regions ; this . emit ( 'loaded-regions' , this . regionList ) ; } }