backend-plugin-api: separate out hook in addShutdownHook

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-02-06 15:54:19 +01:00
parent 2c68a05fd3
commit e716946103
14 changed files with 88 additions and 71 deletions
+9 -4
View File
@@ -294,14 +294,19 @@ export interface IdentityService extends IdentityApi {}
// @public (undocumented)
export interface LifecycleService {
addShutdownHook(options: LifecycleServiceShutdownHook): void;
addShutdownHook(
hook: LifecycleServiceShutdownHook,
options?: LifecycleServiceShutdownOptions,
): void;
}
// @public (undocumented)
export type LifecycleServiceShutdownHook = {
fn: () => void | Promise<void>;
export type LifecycleServiceShutdownHook = () => void | Promise<void>;
// @public (undocumented)
export interface LifecycleServiceShutdownOptions {
logger?: LoggerService;
};
}
// @public
export interface LoggerService {
@@ -19,14 +19,17 @@ import { LoggerService } from './LoggerService';
/**
* @public
*/
export type LifecycleServiceShutdownHook = {
fn: () => void | Promise<void>;
export type LifecycleServiceShutdownHook = () => void | Promise<void>;
/**
* @public
*/
export interface LifecycleServiceShutdownOptions {
/**
* Optional {@link LoggerService} that will be used for logging instead of the default logger.
*/
logger?: LoggerService;
};
}
/**
* @public
@@ -35,5 +38,8 @@ export interface LifecycleService {
/**
* Register a function to be called when the backend is shutting down.
*/
addShutdownHook(options: LifecycleServiceShutdownHook): void;
addShutdownHook(
hook: LifecycleServiceShutdownHook,
options?: LifecycleServiceShutdownOptions,
): void;
}
@@ -28,6 +28,7 @@ export type { HttpRouterService } from './HttpRouterService';
export type {
LifecycleService,
LifecycleServiceShutdownHook,
LifecycleServiceShutdownOptions,
} from './LifecycleService';
export type { LoggerService, LogMeta } from './LoggerService';
export type { PermissionsService } from './PermissionsService';