Merge pull request #15237 from backstage/mob/config-obj

backend-plugin-api: suffix all service interfaces with *Service
This commit is contained in:
Patrik Oldsberg
2022-12-14 17:55:31 +01:00
committed by GitHub
21 changed files with 156 additions and 77 deletions
+11 -8
View File
@@ -4,13 +4,12 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import { BackendLifecycle } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { ExtensionPoint } from '@backstage/backend-plugin-api';
import { HttpRouterService } from '@backstage/backend-plugin-api';
import { Logger } from '@backstage/backend-plugin-api';
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { PluginCacheManager } from '@backstage/backend-common';
import { PluginDatabaseManager } from '@backstage/backend-common';
import { PluginEndpointDiscovery } from '@backstage/backend-common';
@@ -70,18 +69,22 @@ export type HttpRouterFactoryOptions = {
// @public
export const lifecycleFactory: (
options?: undefined,
) => ServiceFactory<BackendLifecycle>;
) => ServiceFactory<LifecycleService>;
// @public (undocumented)
export const loggerFactory: (options?: undefined) => ServiceFactory<Logger>;
export const loggerFactory: (
options?: undefined,
) => ServiceFactory<LoggerService>;
// @public (undocumented)
export const permissionsFactory: (
options?: undefined,
) => ServiceFactory<PermissionAuthorizer | PermissionEvaluator>;
) => ServiceFactory<PermissionsService>;
// @public (undocumented)
export const rootLoggerFactory: (options?: undefined) => ServiceFactory<Logger>;
export const rootLoggerFactory: (
options?: undefined,
) => ServiceFactory<LoggerService>;
// @public (undocumented)
export const schedulerFactory: (
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import {
BackendLifecycle,
LifecycleService,
createServiceFactory,
coreServices,
loggerToWinstonLogger,
BackendLifecycleShutdownHook,
LifecycleServiceShutdownHook,
} from '@backstage/backend-plugin-api';
import { Logger } from 'winston';
@@ -29,11 +29,11 @@ export class BackendLifecycleImpl {
}
#isCalled = false;
#shutdownTasks: Array<BackendLifecycleShutdownHook & { pluginId: string }> =
#shutdownTasks: Array<LifecycleServiceShutdownHook & { pluginId: string }> =
[];
addShutdownHook(
options: BackendLifecycleShutdownHook & { pluginId: string },
options: LifecycleServiceShutdownHook & { pluginId: string },
): void {
this.#shutdownTasks.push(options);
}
@@ -64,12 +64,12 @@ export class BackendLifecycleImpl {
}
}
class PluginScopedLifecycleImpl implements BackendLifecycle {
class PluginScopedLifecycleImpl implements LifecycleService {
constructor(
private readonly lifecycle: BackendLifecycleImpl,
private readonly pluginId: string,
) {}
addShutdownHook(options: BackendLifecycleShutdownHook): void {
addShutdownHook(options: LifecycleServiceShutdownHook): void {
this.lifecycle.addShutdownHook({ ...options, pluginId: this.pluginId });
}
}
@@ -17,12 +17,12 @@
import { createRootLogger } from '@backstage/backend-common';
import {
createServiceFactory,
Logger,
LoggerService,
coreServices,
} from '@backstage/backend-plugin-api';
import { Logger as WinstonLogger } from 'winston';
class BackstageLogger implements Logger {
class BackstageLogger implements LoggerService {
static fromWinston(logger: WinstonLogger): BackstageLogger {
return new BackstageLogger(logger);
}
@@ -33,7 +33,7 @@ class BackstageLogger implements Logger {
this.winston.info(message, ...meta);
}
child(fields: { [name: string]: string }): Logger {
child(fields: { [name: string]: string }): LoggerService {
return new BackstageLogger(this.winston.child(fields));
}
}