Merge pull request #16229 from backstage/blam/bs/cleanup

Update `*Factory` suffix to `*ServiceFactory`
This commit is contained in:
Ben Lambert
2023-02-07 14:28:32 +01:00
committed by GitHub
46 changed files with 166 additions and 176 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch
---
Removing extra imports for `run` script as `TestBackend` auto loads the default factories
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/backend-test-utils': patch
'@backstage/backend-defaults': patch
---
Use the new `*ServiceFactory` exports from `@backstage/backend-app-api`
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-app-api': minor
---
**BREAKING** Renaming `*Factory` exports to `*ServiceFactory` instead. For example `configFactory` now is exported as `configServiceFactory`.
@@ -61,7 +61,7 @@ class DefaultFooService implements FooService {
}
}
export const fooFactory = createServiceFactory({
export const fooServiceFactory = createServiceFactory({
service: fooServiceRef,
deps: { bar: barServiceRef },
factory({ bar }) {
@@ -75,7 +75,7 @@ To create a service factory we need to provide a reference to the `service` for
If you need the creation of the service instance to be asynchronous, you can make the `factory` function async. For example:
```ts
export const fooFactory = createServiceFactory({
export const fooServiceFactory = createServiceFactory({
service: fooServiceRef,
deps: {},
async factory() {
@@ -94,18 +94,18 @@ To install a service factory in a backend instance, we pass it in through the `s
```ts
const backend = createBackend({
services: [fooFactory()],
services: [fooServiceFactory()],
});
```
Note that we call `fooFactory` to create the service factory instance. This is because `createServiceFactory` always returns a factory function that creates the actual service factory. This is done to always allow for options to be added to the service factory in the future, without breaking existing code. To add options to your service factory, you wrap the object passed to `createServiceFactory` in a callback that accepts the desired options. For example:
Note that we call `fooServiceFactory` to create the service factory instance. This is because `createServiceFactory` always returns a factory function that creates the actual service factory. This is done to always allow for options to be added to the service factory in the future, without breaking existing code. To add options to your service factory, you wrap the object passed to `createServiceFactory` in a callback that accepts the desired options. For example:
```ts
export interface FooFactoryOptions {
mode: 'eager' | 'lazy';
}
export const fooFactory = createServiceFactory(
export const fooServiceFactory = createServiceFactory(
(options?: FooFactoryOptions) => ({
service: fooServiceRef,
deps: { bar: barServiceRef },
@@ -120,7 +120,7 @@ This lets us use the options to customize the factory implementation in any way
```ts
const backend = createBackend({
services: [fooFactory({ mode: 'eager' })],
services: [fooServiceFactory({ mode: 'eager' })],
});
```
@@ -164,7 +164,7 @@ Plugin scoped services have access to a plugin metadata service, which is a spec
The plugin metadata service is the base for all plugin specific customizations for services. For example, the default implementation of the plugin scoped logger service uses the plugin metadata service to attach the plugin ID as a field in all log messages:
```ts
export const loggerFactory = createServiceFactory({
export const loggerServiceFactory = createServiceFactory({
service: coreServices.logger,
deps: {
rootLogger: coreServices.rootLogger,
@@ -183,7 +183,7 @@ Some services may benefit from having a context that is shared across all instan
The root context is defined as part of the service factory by passing the `createRootContext` option:
```ts
export const fooFactory = createServiceFactory({
export const fooServiceFactory = createServiceFactory({
service: fooServiceRef,
deps: { rootLogger: coreServices.rootLogger, bar: barServiceRef },
createRootContext({ rootLogger }) {
@@ -66,12 +66,12 @@ export const catalogProcessingExtensionPoint = createExtensionPoint<CatalogProce
### Services
| Description | Pattern | Examples |
| ----------- | ------------------- | -------------------------------------------------- |
| Interface | `<Name>Service` | `LoggerService`, `DatabaseService` |
| Reference | `<name>ServiceRef` | `loggerServiceRef`, `databaseServiceRef` |
| ID | `<pluginId>.<name>` | `'core.rootHttpRouter'`, `'catalog.catalogClient'` |
| Factory | `<name>Factory` | `loggerFactory`, `databaseFactory` |
| Description | Pattern | Examples |
| ----------- | ---------------------- | -------------------------------------------------- |
| Interface | `<Name>Service` | `LoggerService`, `DatabaseService` |
| Reference | `<name>ServiceRef` | `loggerServiceRef`, `databaseServiceRef` |
| ID | `<pluginId>.<name>` | `'core.rootHttpRouter'`, `'catalog.catalogClient'` |
| Factory | `<name>ServiceFactory` | `loggerServiceFactory`, `databaseServiceFactory` |
Example:
@@ -85,7 +85,7 @@ export const catalogClientServiceRef = createServiceRef<CatalogClientService>({
...
})
export const catalogClientFactory = createServiceFactory({
export const catalogClientServiceFactory = createServiceFactory({
service: catalogClientServiceRef,
...
})
@@ -61,11 +61,11 @@ All of these services can be replaced with your own implementations if you need
For example, let's say we want to customize the core configuration service to enable remote configuration loading. That would look something like this:
```ts
import { configFactory } from '@backstage/backend-app-api';
import { configServiceFactory } from '@backstage/backend-app-api';
const backend = createBackend({
services: [
configFactory({
configServiceFactory({
remote: { reloadIntervalSeconds: 60 },
}),
],
@@ -160,11 +160,11 @@ A shared environment is defined using `createSharedEnvironment`. In this example
```ts
// packages/backend-env/src/index.ts
import { createSharedEnvironment } from '@backstage/backend-plugin-api';
import { customDiscoveryFactory } from './customDiscoveryFactory';
import { customDiscoveryServiceFactory } from './customDiscoveryServiceFactory';
export const env = createSharedEnvironment({
services: [
customDiscoveryFactory(), // custom DiscoveryService implementation
customDiscoveryServiceFactory(), // custom DiscoveryService implementation
],
});
```
@@ -59,11 +59,11 @@ There's additional configuration that you can optionally pass to setup the `http
You can configure these additional options by adding an override for the core service when calling `createBackend` like follows:
```ts
import { httpRouterFactory } from '@backstage/backend-app-api';
import { httpRouterServiceFactory } from '@backstage/backend-app-api';
const backend = createBackend({
services: [
httpRouterFactory({
httpRouterServiceFactory({
getPath: (pluginId: string) => `/plugins/${pluginId}`,
}),
],
@@ -116,11 +116,11 @@ There's additional options that you can pass to configure the root HTTP Router s
You can configure the root HTTP Router service by passing the options to the `createBackend` function.
```ts
import { rootHttpRouterFactory } from '@backstage/backend-app-api';
import { rootHttpRouterServiceFactory } from '@backstage/backend-app-api';
const backend = createBackend({
services: [
rootHttpRouterFactory({
rootHttpRouterServiceFactory({
configure: ({ app, middleware, routes, config, logger, lifecycle }) => {
// the built in middleware is provided through an option in the configure function
app.use(middleware.helmet());
@@ -183,11 +183,11 @@ There's additional configuration that you can optionally pass to setup the `conf
You can configure these additional options by adding an override for the core service when calling `createBackend` like follows:
```ts
import { configFactory } from '@backstage/backend-app-api';
import { configServiceFactory } from '@backstage/backend-app-api';
const backend = createBackend({
services: [
configFactory({
configServiceFactory({
argv: [
'--config',
'/backstage/app-config.development.yaml',
@@ -438,11 +438,11 @@ There's additional configuration that you can optionally pass to setup the `iden
You can configure these additional options by adding an override for the core service when calling `createBackend` like follows:
```ts
import { identityFactory } from '@backstage/backend-app-api';
import { identityServiceFactory } from '@backstage/backend-app-api';
const backend = createBackend({
services: [
identityFactory({
identityServiceFactory({
issuer: 'backstage',
algorithms: ['ES256', 'RS256'],
}),
+31 -31
View File
@@ -50,12 +50,7 @@ export interface Backend {
}
// @public (undocumented)
export const cacheFactory: () => ServiceFactory<PluginCacheManager>;
// @public (undocumented)
export const configFactory: (
options?: ConfigFactoryOptions | undefined,
) => ServiceFactory<ConfigService>;
export const cacheServiceFactory: () => ServiceFactory<PluginCacheManager>;
// @public (undocumented)
export interface ConfigFactoryOptions {
@@ -63,6 +58,11 @@ export interface ConfigFactoryOptions {
remote?: LoadConfigOptionsRemote;
}
// @public (undocumented)
export const configServiceFactory: (
options?: ConfigFactoryOptions | undefined,
) => ServiceFactory<ConfigService>;
// @public (undocumented)
export function createConfigSecretEnumerator(options: {
logger: LoggerService;
@@ -90,7 +90,7 @@ export interface CreateSpecializedBackendOptions {
}
// @public (undocumented)
export const databaseFactory: () => ServiceFactory<PluginDatabaseManager>;
export const databaseServiceFactory: () => ServiceFactory<PluginDatabaseManager>;
// @public
export class DefaultRootHttpRouter implements RootHttpRouterService {
@@ -108,7 +108,7 @@ export interface DefaultRootHttpRouterOptions {
}
// @public (undocumented)
export const discoveryFactory: () => ServiceFactory<PluginEndpointDiscovery>;
export const discoveryServiceFactory: () => ServiceFactory<PluginEndpointDiscovery>;
// @public
export interface ExtendedHttpServer extends http.Server {
@@ -120,16 +120,16 @@ export interface ExtendedHttpServer extends http.Server {
stop(): Promise<void>;
}
// @public (undocumented)
export const httpRouterFactory: (
options?: HttpRouterFactoryOptions | undefined,
) => ServiceFactory<HttpRouterService>;
// @public (undocumented)
export interface HttpRouterFactoryOptions {
getPath?(pluginId: string): string;
}
// @public (undocumented)
export const httpRouterServiceFactory: (
options?: HttpRouterFactoryOptions | undefined,
) => ServiceFactory<HttpRouterService>;
// @public
export type HttpServerCertificateOptions =
| {
@@ -153,19 +153,19 @@ export type HttpServerOptions = {
};
};
// @public (undocumented)
export const identityFactory: (
options?: IdentityFactoryOptions | undefined,
) => ServiceFactory<IdentityService>;
// @public
export type IdentityFactoryOptions = {
issuer?: string;
algorithms?: string[];
};
// @public (undocumented)
export const identityServiceFactory: (
options?: IdentityFactoryOptions | undefined,
) => ServiceFactory<IdentityService>;
// @public
export const lifecycleFactory: () => ServiceFactory<LifecycleService>;
export const lifecycleServiceFactory: () => ServiceFactory<LifecycleService>;
// @public
export function loadBackendConfig(options: {
@@ -176,7 +176,7 @@ export function loadBackendConfig(options: {
}>;
// @public (undocumented)
export const loggerFactory: () => ServiceFactory<LoggerService>;
export const loggerServiceFactory: () => ServiceFactory<LoggerService>;
// @public
export class MiddlewareFactory {
@@ -204,7 +204,7 @@ export interface MiddlewareFactoryOptions {
}
// @public (undocumented)
export const permissionsFactory: () => ServiceFactory<PermissionsService>;
export const permissionsServiceFactory: () => ServiceFactory<PermissionsService>;
// @public
export function readCorsOptions(config?: Config): CorsOptions;
@@ -231,25 +231,25 @@ export interface RootHttpRouterConfigureOptions {
routes: RequestHandler;
}
// @public (undocumented)
export const rootHttpRouterFactory: (
options?: RootHttpRouterFactoryOptions | undefined,
) => ServiceFactory<RootHttpRouterService>;
// @public (undocumented)
export type RootHttpRouterFactoryOptions = {
indexPath?: string | false;
configure?(options: RootHttpRouterConfigureOptions): void;
};
// @public (undocumented)
export const rootHttpRouterServiceFactory: (
options?: RootHttpRouterFactoryOptions | undefined,
) => ServiceFactory<RootHttpRouterService>;
// @public
export const rootLifecycleFactory: () => ServiceFactory<RootLifecycleService>;
export const rootLifecycleServiceFactory: () => ServiceFactory<RootLifecycleService>;
// @public (undocumented)
export const rootLoggerFactory: () => ServiceFactory<RootLoggerService>;
export const rootLoggerServiceFactory: () => ServiceFactory<RootLoggerService>;
// @public (undocumented)
export const schedulerFactory: () => ServiceFactory<SchedulerService>;
export const schedulerServiceFactory: () => ServiceFactory<SchedulerService>;
// @public (undocumented)
export type ServiceOrExtensionPoint<T = unknown> =
@@ -257,10 +257,10 @@ export type ServiceOrExtensionPoint<T = unknown> =
| ServiceRef<T>;
// @public (undocumented)
export const tokenManagerFactory: () => ServiceFactory<TokenManagerService>;
export const tokenManagerServiceFactory: () => ServiceFactory<TokenManagerService>;
// @public (undocumented)
export const urlReaderFactory: () => ServiceFactory<UrlReader>;
export const urlReaderServiceFactory: () => ServiceFactory<UrlReader>;
// @public
export class WinstonLogger implements RootLoggerService {
@@ -21,7 +21,7 @@ import {
} from '@backstage/backend-plugin-api';
/** @public */
export const cacheFactory = createServiceFactory({
export const cacheServiceFactory = createServiceFactory({
service: coreServices.cache,
deps: {
config: coreServices.config,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { cacheFactory } from './cacheFactory';
export { cacheServiceFactory } from './cacheServiceFactory';
@@ -35,7 +35,7 @@ export interface ConfigFactoryOptions {
}
/** @public */
export const configFactory = createServiceFactory(
export const configServiceFactory = createServiceFactory(
(options?: ConfigFactoryOptions) => ({
service: coreServices.config,
deps: {},
@@ -14,5 +14,5 @@
* limitations under the License.
*/
export { configFactory } from './configFactory';
export type { ConfigFactoryOptions } from './configFactory';
export { configServiceFactory } from './configServiceFactory';
export type { ConfigFactoryOptions } from './configServiceFactory';
@@ -22,7 +22,7 @@ import {
import { ConfigReader } from '@backstage/config';
/** @public */
export const databaseFactory = createServiceFactory({
export const databaseServiceFactory = createServiceFactory({
service: coreServices.database,
deps: {
config: coreServices.config,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { databaseFactory } from './databaseFactory';
export { databaseServiceFactory } from './databaseServiceFactory';
@@ -21,7 +21,7 @@ import {
} from '@backstage/backend-plugin-api';
/** @public */
export const discoveryFactory = createServiceFactory({
export const discoveryServiceFactory = createServiceFactory({
service: coreServices.discovery,
deps: {
config: coreServices.config,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { discoveryFactory } from './discoveryFactory';
export { discoveryServiceFactory } from './discoveryServiceFactory';
@@ -18,12 +18,12 @@ import {
HttpRouterService,
ServiceFactory,
} from '@backstage/backend-plugin-api';
import { httpRouterFactory } from './httpRouterFactory';
import { httpRouterServiceFactory } from './httpRouterServiceFactory';
describe('httpRouterFactory', () => {
it('should register plugin paths', async () => {
const rootHttpRouter = { use: jest.fn() };
const factory = httpRouterFactory() as Exclude<
const factory = httpRouterServiceFactory() as Exclude<
ServiceFactory<HttpRouterService>,
{ scope: 'root' }
>;
@@ -55,7 +55,7 @@ describe('httpRouterFactory', () => {
it('should use custom path generator', async () => {
const rootHttpRouter = { use: jest.fn() };
const factory = httpRouterFactory({
const factory = httpRouterServiceFactory({
getPath: id => `/some/${id}/path`,
}) as Exclude<ServiceFactory<HttpRouterService>, { scope: 'root' }>;
@@ -31,7 +31,7 @@ export interface HttpRouterFactoryOptions {
}
/** @public */
export const httpRouterFactory = createServiceFactory(
export const httpRouterServiceFactory = createServiceFactory(
(options?: HttpRouterFactoryOptions) => ({
service: coreServices.httpRouter,
deps: {
@@ -14,5 +14,5 @@
* limitations under the License.
*/
export { httpRouterFactory } from './httpRouterFactory';
export type { HttpRouterFactoryOptions } from './httpRouterFactory';
export { httpRouterServiceFactory } from './httpRouterServiceFactory';
export type { HttpRouterFactoryOptions } from './httpRouterServiceFactory';
@@ -34,7 +34,7 @@ export type IdentityFactoryOptions = {
};
/** @public */
export const identityFactory = createServiceFactory(
export const identityServiceFactory = createServiceFactory(
(options?: IdentityFactoryOptions) => ({
service: coreServices.identity,
deps: {
@@ -14,5 +14,5 @@
* limitations under the License.
*/
export { identityFactory } from './identityFactory';
export type { IdentityFactoryOptions } from './identityFactory';
export { identityServiceFactory } from './identityServiceFactory';
export type { IdentityFactoryOptions } from './identityServiceFactory';
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { lifecycleFactory } from './lifecycleFactory';
export { lifecycleServiceFactory } from './lifecycleServiceFactory';
@@ -24,7 +24,7 @@ import {
* Allows plugins to register shutdown hooks that are run when the process is about to exit.
* @public
*/
export const lifecycleFactory = createServiceFactory({
export const lifecycleServiceFactory = createServiceFactory({
service: coreServices.lifecycle,
deps: {
logger: coreServices.logger,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { loggerFactory } from './loggerFactory';
export { loggerServiceFactory } from './loggerServiceFactory';
@@ -20,7 +20,7 @@ import {
} from '@backstage/backend-plugin-api';
/** @public */
export const loggerFactory = createServiceFactory({
export const loggerServiceFactory = createServiceFactory({
service: coreServices.logger,
deps: {
rootLogger: coreServices.rootLogger,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { permissionsFactory } from './permissionsFactory';
export { permissionsServiceFactory } from './permissionsServiceFactory';
@@ -21,7 +21,7 @@ import {
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
/** @public */
export const permissionsFactory = createServiceFactory({
export const permissionsServiceFactory = createServiceFactory({
service: coreServices.permissions,
deps: {
config: coreServices.config,
@@ -15,10 +15,10 @@
*/
export {
rootHttpRouterFactory,
rootHttpRouterServiceFactory,
type RootHttpRouterFactoryOptions,
type RootHttpRouterConfigureOptions,
} from './rootHttpRouterFactory';
} from './rootHttpRouterServiceFactory';
export {
DefaultRootHttpRouter,
type DefaultRootHttpRouterOptions,
@@ -69,7 +69,7 @@ function defaultConfigure({
}
/** @public */
export const rootHttpRouterFactory = createServiceFactory(
export const rootHttpRouterServiceFactory = createServiceFactory(
(options?: RootHttpRouterFactoryOptions) => ({
service: coreServices.rootHttpRouter,
deps: {
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { rootLifecycleFactory } from './rootLifecycleFactory';
export { rootLifecycleServiceFactory } from './rootLifecycleServiceFactory';
@@ -15,7 +15,7 @@
*/
import { getVoidLogger } from '@backstage/backend-common';
import { BackendLifecycleImpl } from './rootLifecycleFactory';
import { BackendLifecycleImpl } from './rootLifecycleServiceFactory';
describe('lifecycleService', () => {
it('should execute registered shutdown hook', async () => {
@@ -65,7 +65,7 @@ export class BackendLifecycleImpl implements RootLifecycleService {
*
* @public
*/
export const rootLifecycleFactory = createServiceFactory({
export const rootLifecycleServiceFactory = createServiceFactory({
service: coreServices.rootLifecycle,
deps: {
logger: coreServices.rootLogger,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { rootLoggerFactory } from './rootLoggerFactory';
export { rootLoggerServiceFactory } from './rootLoggerServiceFactory';
@@ -23,7 +23,7 @@ import { transports, format } from 'winston';
import { createConfigSecretEnumerator } from '../../../config';
/** @public */
export const rootLoggerFactory = createServiceFactory({
export const rootLoggerServiceFactory = createServiceFactory({
service: coreServices.rootLogger,
deps: {
config: coreServices.config,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { schedulerFactory } from './schedulerFactory';
export { schedulerServiceFactory } from './schedulerServiceFactory';
@@ -19,13 +19,13 @@ import {
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { startTestBackend } from '@backstage/backend-test-utils';
import { schedulerFactory } from './schedulerFactory';
import { schedulerServiceFactory } from './schedulerServiceFactory';
describe('schedulerFactory', () => {
it('creates sidecar database features', async () => {
expect.assertions(3);
const subject = schedulerFactory();
const subject = schedulerServiceFactory();
const plugin = createBackendPlugin({
pluginId: 'example',
@@ -22,7 +22,7 @@ import {
import { TaskScheduler } from '@backstage/backend-tasks';
/** @public */
export const schedulerFactory = createServiceFactory({
export const schedulerServiceFactory = createServiceFactory({
service: coreServices.scheduler,
deps: {
plugin: coreServices.pluginMetadata,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { tokenManagerFactory } from './tokenManagerFactory';
export { tokenManagerServiceFactory } from './tokenManagerServiceFactory';
@@ -20,13 +20,13 @@ import {
TokenManagerService,
} from '@backstage/backend-plugin-api';
import { ConfigReader } from '@backstage/config';
import { tokenManagerFactory } from './tokenManagerFactory';
import { tokenManagerServiceFactory } from './tokenManagerServiceFactory';
describe('tokenManagerFactory', () => {
it('should create managers that can share tokens in development', async () => {
(process.env as { NODE_ENV?: string }).NODE_ENV = 'development';
const factory = tokenManagerFactory() as Exclude<
const factory = tokenManagerServiceFactory() as Exclude<
ServiceFactory<TokenManagerService>,
{ scope: 'root' }
>;
@@ -21,7 +21,7 @@ import {
import { ServerTokenManager } from '@backstage/backend-common';
/** @public */
export const tokenManagerFactory = createServiceFactory({
export const tokenManagerServiceFactory = createServiceFactory({
service: coreServices.tokenManager,
deps: {
config: coreServices.config,
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { urlReaderFactory } from './urlReaderFactory';
export { urlReaderServiceFactory } from './urlReaderServiceFactory';
@@ -21,7 +21,7 @@ import {
} from '@backstage/backend-plugin-api';
/** @public */
export const urlReaderFactory = createServiceFactory({
export const urlReaderServiceFactory = createServiceFactory({
service: coreServices.urlReader,
deps: {
config: coreServices.config,
@@ -20,7 +20,7 @@ import {
coreServices,
ServiceRef,
} from '@backstage/backend-plugin-api';
import { BackendLifecycleImpl } from '../services/implementations/rootLifecycle/rootLifecycleFactory';
import { BackendLifecycleImpl } from '../services/implementations/rootLifecycle/rootLifecycleServiceFactory';
import {
BackendRegisterInit,
EnumerableServiceHolder,
+30 -30
View File
@@ -16,22 +16,22 @@
import {
Backend,
cacheFactory,
configFactory,
cacheServiceFactory,
configServiceFactory,
createSpecializedBackend,
databaseFactory,
discoveryFactory,
httpRouterFactory,
rootHttpRouterFactory,
lifecycleFactory,
rootLifecycleFactory,
loggerFactory,
permissionsFactory,
rootLoggerFactory,
schedulerFactory,
tokenManagerFactory,
urlReaderFactory,
identityFactory,
databaseServiceFactory,
discoveryServiceFactory,
httpRouterServiceFactory,
rootHttpRouterServiceFactory,
lifecycleServiceFactory,
rootLifecycleServiceFactory,
loggerServiceFactory,
permissionsServiceFactory,
rootLoggerServiceFactory,
schedulerServiceFactory,
tokenManagerServiceFactory,
urlReaderServiceFactory,
identityServiceFactory,
} from '@backstage/backend-app-api';
import {
ServiceFactory,
@@ -44,21 +44,21 @@ import {
import type { InternalSharedBackendEnvironment } from '@backstage/backend-plugin-api/src/wiring/createSharedEnvironment';
export const defaultServiceFactories = [
cacheFactory(),
configFactory(),
databaseFactory(),
discoveryFactory(),
httpRouterFactory(),
identityFactory(),
lifecycleFactory(),
loggerFactory(),
permissionsFactory(),
rootHttpRouterFactory(),
rootLifecycleFactory(),
rootLoggerFactory(),
schedulerFactory(),
tokenManagerFactory(),
urlReaderFactory(),
cacheServiceFactory(),
configServiceFactory(),
databaseServiceFactory(),
discoveryServiceFactory(),
httpRouterServiceFactory(),
identityServiceFactory(),
lifecycleServiceFactory(),
loggerServiceFactory(),
permissionsServiceFactory(),
rootHttpRouterServiceFactory(),
rootLifecycleServiceFactory(),
rootLoggerServiceFactory(),
schedulerServiceFactory(),
tokenManagerServiceFactory(),
urlReaderServiceFactory(),
];
/**
@@ -25,15 +25,15 @@ import {
TokenManagerService,
} from '@backstage/backend-plugin-api';
import {
cacheFactory,
databaseFactory,
httpRouterFactory,
lifecycleFactory,
loggerFactory,
permissionsFactory,
rootLifecycleFactory,
schedulerFactory,
urlReaderFactory,
cacheServiceFactory,
databaseServiceFactory,
httpRouterServiceFactory,
lifecycleServiceFactory,
loggerServiceFactory,
permissionsServiceFactory,
rootLifecycleServiceFactory,
schedulerServiceFactory,
urlReaderServiceFactory,
} from '@backstage/backend-app-api';
import { ConfigReader } from '@backstage/config';
import { JsonObject } from '@backstage/types';
@@ -107,30 +107,30 @@ export namespace mockServices {
// some may need a bit more refactoring for it to be simpler to
// re-implement functioning mock versions here.
export namespace cache {
export const factory = cacheFactory;
export const factory = cacheServiceFactory;
}
export namespace database {
export const factory = databaseFactory;
export const factory = databaseServiceFactory;
}
export namespace httpRouter {
export const factory = httpRouterFactory;
export const factory = httpRouterServiceFactory;
}
export namespace lifecycle {
export const factory = lifecycleFactory;
export const factory = lifecycleServiceFactory;
}
export namespace logger {
export const factory = loggerFactory;
export const factory = loggerServiceFactory;
}
export namespace permissions {
export const factory = permissionsFactory;
export const factory = permissionsServiceFactory;
}
export namespace rootLifecycle {
export const factory = rootLifecycleFactory;
export const factory = rootLifecycleServiceFactory;
}
export namespace scheduler {
export const factory = schedulerFactory;
export const factory = schedulerServiceFactory;
}
export namespace urlReader {
export const factory = urlReaderFactory;
export const factory = urlReaderServiceFactory;
}
}
@@ -13,20 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line @backstage/no-undeclared-imports
import {
databaseFactory,
discoveryFactory,
httpRouterFactory,
lifecycleFactory,
loggerFactory,
permissionsFactory,
rootLoggerFactory,
schedulerFactory,
tokenManagerFactory,
urlReaderFactory,
} from '@backstage/backend-app-api';
import { coreServices } from '@backstage/backend-plugin-api';
import { startTestBackend } from '@backstage/backend-test-utils';
import { ConfigReader } from '@backstage/config';
@@ -61,19 +47,7 @@ async function main() {
};
await startTestBackend({
services: [
[coreServices.config, new ConfigReader(config)],
databaseFactory(),
discoveryFactory(),
httpRouterFactory(),
lifecycleFactory(),
loggerFactory(),
permissionsFactory(),
rootLoggerFactory(),
schedulerFactory(),
tokenManagerFactory(),
urlReaderFactory(),
],
services: [[coreServices.config, new ConfigReader(config)]],
extensionPoints: [],
features: [
catalogPlugin(),