backend-plugin-api: suffix all service interfaces with *Service
Co-authored-by: Johan Haals <johan.haals@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -17,9 +17,12 @@
|
||||
import { createServiceRef } from '../system/types';
|
||||
import { PluginCacheManager } from '@backstage/backend-common';
|
||||
|
||||
/** @public */
|
||||
export type CacheService = PluginCacheManager;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const cacheServiceRef = createServiceRef<PluginCacheManager>({
|
||||
export const cacheServiceRef = createServiceRef<CacheService>({
|
||||
id: 'core.cache',
|
||||
});
|
||||
|
||||
@@ -20,7 +20,12 @@ import { createServiceRef } from '../system/types';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const configServiceRef = createServiceRef<Config>({
|
||||
export type ConfigService = Config;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const configServiceRef = createServiceRef<ConfigService>({
|
||||
id: 'core.root.config',
|
||||
scope: 'root',
|
||||
});
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
import { PluginDatabaseManager } from '@backstage/backend-common';
|
||||
import { createServiceRef } from '../system/types';
|
||||
|
||||
/** @public */
|
||||
export type DatabaseService = PluginDatabaseManager;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const databaseServiceRef = createServiceRef<PluginDatabaseManager>({
|
||||
export const databaseServiceRef = createServiceRef<DatabaseService>({
|
||||
id: 'core.database',
|
||||
});
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
import { createServiceRef } from '../system/types';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
|
||||
/** @public */
|
||||
export type DiscoveryService = PluginEndpointDiscovery;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const discoveryServiceRef = createServiceRef<PluginEndpointDiscovery>({
|
||||
export const discoveryServiceRef = createServiceRef<DiscoveryService>({
|
||||
id: 'core.discovery',
|
||||
});
|
||||
|
||||
@@ -17,10 +17,19 @@
|
||||
import * as coreServices from './coreServices';
|
||||
|
||||
export { coreServices };
|
||||
export type { CacheService } from './cacheServiceRef';
|
||||
export type { ConfigService } from './configServiceRef';
|
||||
export type { DatabaseService } from './databaseServiceRef';
|
||||
export type { DiscoveryService } from './discoveryServiceRef';
|
||||
export type { HttpRouterService } from './httpRouterServiceRef';
|
||||
export type { Logger } from './loggerServiceRef';
|
||||
export type {
|
||||
BackendLifecycle,
|
||||
BackendLifecycleShutdownHook,
|
||||
LifecycleService,
|
||||
LifecycleServiceShutdownHook,
|
||||
} from './lifecycleServiceRef';
|
||||
export type { PluginMetadata } from './pluginMetadataServiceRef';
|
||||
export type { LoggerService } from './loggerServiceRef';
|
||||
export type { PermissionsService } from './permissionsServiceRef';
|
||||
export type { PluginMetadataService } from './pluginMetadataServiceRef';
|
||||
export type { RootLoggerService } from './rootLoggerServiceRef';
|
||||
export type { SchedulerService } from './schedulerServiceRef';
|
||||
export type { TokenManagerService } from './tokenManagerServiceRef';
|
||||
export type { UrlReaderService } from './urlReaderServiceRef';
|
||||
|
||||
@@ -19,24 +19,24 @@ import { createServiceRef } from '../system/types';
|
||||
/**
|
||||
* @public
|
||||
**/
|
||||
export type BackendLifecycleShutdownHook = {
|
||||
export type LifecycleServiceShutdownHook = {
|
||||
fn: () => void | Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
**/
|
||||
export interface BackendLifecycle {
|
||||
export interface LifecycleService {
|
||||
/**
|
||||
* Register a function to be called when the backend is shutting down.
|
||||
*/
|
||||
addShutdownHook(options: BackendLifecycleShutdownHook): void;
|
||||
addShutdownHook(options: LifecycleServiceShutdownHook): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const lifecycleServiceRef = createServiceRef<BackendLifecycle>({
|
||||
export const lifecycleServiceRef = createServiceRef<LifecycleService>({
|
||||
id: 'core.lifecycle',
|
||||
scope: 'plugin',
|
||||
});
|
||||
|
||||
@@ -19,14 +19,14 @@ import { createServiceRef } from '../system/types';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Logger {
|
||||
export interface LoggerService {
|
||||
info(message: string): void;
|
||||
child(fields: { [name: string]: string }): Logger;
|
||||
child(fields: { [name: string]: string }): LoggerService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const loggerServiceRef = createServiceRef<Logger>({
|
||||
export const loggerServiceRef = createServiceRef<LoggerService>({
|
||||
id: 'core.logger',
|
||||
});
|
||||
|
||||
@@ -20,11 +20,12 @@ import {
|
||||
PermissionEvaluator,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
|
||||
/** @public */
|
||||
export type PermissionsService = PermissionEvaluator | PermissionAuthorizer;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const permissionsServiceRef = createServiceRef<
|
||||
PermissionEvaluator | PermissionAuthorizer
|
||||
>({
|
||||
export const permissionsServiceRef = createServiceRef<PermissionsService>({
|
||||
id: 'core.permissions',
|
||||
});
|
||||
|
||||
@@ -19,13 +19,15 @@ import { createServiceRef } from '../system/types';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface PluginMetadata {
|
||||
export interface PluginMetadataService {
|
||||
getId(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const pluginMetadataServiceRef = createServiceRef<PluginMetadata>({
|
||||
id: 'core.plugin-metadata',
|
||||
});
|
||||
export const pluginMetadataServiceRef = createServiceRef<PluginMetadataService>(
|
||||
{
|
||||
id: 'core.plugin-metadata',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -15,12 +15,15 @@
|
||||
*/
|
||||
|
||||
import { createServiceRef } from '../system/types';
|
||||
import { Logger } from './loggerServiceRef';
|
||||
import { LoggerService } from './loggerServiceRef';
|
||||
|
||||
/** @public */
|
||||
export type RootLoggerService = LoggerService;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const rootLoggerServiceRef = createServiceRef<Logger>({
|
||||
export const rootLoggerServiceRef = createServiceRef<RootLoggerService>({
|
||||
id: 'core.root.logger',
|
||||
scope: 'root',
|
||||
});
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
import { createServiceRef } from '../system/types';
|
||||
import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
||||
|
||||
/** @public */
|
||||
export type SchedulerService = PluginTaskScheduler;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const schedulerServiceRef = createServiceRef<PluginTaskScheduler>({
|
||||
export const schedulerServiceRef = createServiceRef<SchedulerService>({
|
||||
id: 'core.scheduler',
|
||||
});
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
import { createServiceRef } from '../system/types';
|
||||
import { TokenManager } from '@backstage/backend-common';
|
||||
|
||||
/** @public */
|
||||
export type TokenManagerService = TokenManager;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const tokenManagerServiceRef = createServiceRef<TokenManager>({
|
||||
export const tokenManagerServiceRef = createServiceRef<TokenManagerService>({
|
||||
id: 'core.tokenManager',
|
||||
});
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
import { createServiceRef } from '../system/types';
|
||||
import { UrlReader } from '@backstage/backend-common';
|
||||
|
||||
/** @public */
|
||||
export type UrlReaderService = UrlReader;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const urlReaderServiceRef = createServiceRef<UrlReader>({
|
||||
export const urlReaderServiceRef = createServiceRef<UrlReaderService>({
|
||||
id: 'core.urlReader',
|
||||
});
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Logger as BackstageLogger } from '../definitions';
|
||||
import { LoggerService } from '../definitions';
|
||||
import { Logger as WinstonLogger, createLogger } from 'winston';
|
||||
import Transport, { TransportStreamOptions } from 'winston-transport';
|
||||
|
||||
class BackstageLoggerTransport extends Transport {
|
||||
constructor(
|
||||
private readonly backstageLogger: BackstageLogger,
|
||||
private readonly backstageLogger: LoggerService,
|
||||
opts?: TransportStreamOptions,
|
||||
) {
|
||||
super(opts);
|
||||
@@ -35,7 +35,7 @@ class BackstageLoggerTransport extends Transport {
|
||||
|
||||
/** @public */
|
||||
export function loggerToWinstonLogger(
|
||||
logger: BackstageLogger,
|
||||
logger: LoggerService,
|
||||
opts?: TransportStreamOptions,
|
||||
): WinstonLogger {
|
||||
return createLogger({
|
||||
|
||||
Reference in New Issue
Block a user