/** * Define controls for managing entity lifecycle. */ export declare namespace Startable { /** * states for a Startable entity */ enum State { STOPPED = "stopped", STARTING = "starting", RUNNING = "running", STOPPING = "stopping" } /** * define the structure of a Startable entity */ interface IController { /** * current status of the entity */ state: State; /** * handle the startup of an entity * * updates `state` according to lifecycle * * @returns {Promise} */ start(): Promise; /** * handle the teardown of an entity * * updates `state` according to lifecycle * * @returns {Promise} */ stop(): Promise; } abstract class Controller implements IController { state: State; /** * internal method to define specific startup routine * * used by `start()` internally * * implement with `protected` to keep hidden from class interface */ protected abstract _start(): Promise; /** * internal method to define teardown routine * * used by `stop()` internally * * implement with `protected` to keep hidden from class interface */ protected abstract _stop(): Promise; start(): Promise; stop(): Promise; } }