/** * This namespace handles the basic lifecycle of the components. * @public */ export declare namespace Lifecycle { type ComponentBasedProgram = { /** * async stop() finishes all the components of the service and awaits for completion * it should be called to gracefully stop the program. * * It is automatically called on SIGTERM */ stop(): Promise; /** * The components are present here only for debugging reasons. Do not use * it as part of your program. */ readonly components: Components; }; type EntryPointParameters = ComponentBasedProgram & { /** * The program must wire all components together and then call startComponents * before exiting the main() function. Otherwise it will raise an error. */ startComponents(): Promise; /** * The program can register handlers to be run before stopping all components */ beforeStopComponents(callback: () => Promise): void; }; /** * Program lifecycle configurations */ type ProgramConfig = { /** * async main(program)\{ .. \} entry point of the application. * It should wire components together i.e. wiring routes to http-servers * and listeners to kafka. * * The main function must also call the program. * * Example: * ```ts * async main(program) { * const { components, startComponents } = program * components.server.use(routeHandler) * * // start all components, including http listener * await startComponents() * } * ``` */ main: (program: EntryPointParameters) => Promise; /** * initComponents is a function that returns the components to be used by * the app. */ initComponents: () => Promise; }; /** * Program entry point, this should be the one and only top level * expression of your program. */ function run>(config: ProgramConfig): PromiseLike>; } //# sourceMappingURL=lifecycle.d.ts.map