Rename HealthService to RootHealthService
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -20,7 +20,6 @@ import { coreServices } from '@backstage/backend-plugin-api';
|
||||
- [Cache Service](./cache.md) - Key-value store for caching data.
|
||||
- [Database Service](./database.md) - Database access and management via [knex](https://knexjs.org/).
|
||||
- [Discovery Service](./discovery.md) - Service discovery for inter-plugin communication.
|
||||
- [Health Service](./health.md) - Health check endpoints for the backend.
|
||||
- [Http Auth Service](./http-auth.md) - Authentication of HTTP requests.
|
||||
- [Http Router Service](./http-router.md) - HTTP route registration for plugins.
|
||||
- [Identity Service](./identity.md) - Deprecated user authentication service, use the [Auth Service](./auth.md) instead.
|
||||
@@ -29,6 +28,7 @@ import { coreServices } from '@backstage/backend-plugin-api';
|
||||
- [Permissions Service](./permissions.md) - Permission system integration for authorization of user actions.
|
||||
- [Plugin Metadata Service](./plugin-metadata.md) - Built-in service for accessing metadata about the current plugin.
|
||||
- [Root Config Service](./root-config.md) - Access to static configuration.
|
||||
- [Root Health Service](./root-health.md) - Health check endpoints for the backend.
|
||||
- [Root Http Router Service](./root-http-router.md) - HTTP route registration for root services.
|
||||
- [Root Lifecycle Service](./root-lifecycle.md) - Registration of backend startup and shutdown lifecycle hooks.
|
||||
- [Root Logger Service](./root-logger.md) - Root-level logging.
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
"./cache": "./src/entrypoints/cache/index.ts",
|
||||
"./database": "./src/entrypoints/database/index.ts",
|
||||
"./discovery": "./src/entrypoints/discovery/index.ts",
|
||||
"./health": "./src/entrypoints/health/index.ts",
|
||||
"./httpAuth": "./src/entrypoints/httpAuth/index.ts",
|
||||
"./httpRouter": "./src/entrypoints/httpRouter/index.ts",
|
||||
"./lifecycle": "./src/entrypoints/lifecycle/index.ts",
|
||||
"./logger": "./src/entrypoints/logger/index.ts",
|
||||
"./permissions": "./src/entrypoints/permissions/index.ts",
|
||||
"./rootConfig": "./src/entrypoints/rootConfig/index.ts",
|
||||
"./rootHealth": "./src/entrypoints/rootHealth/index.ts",
|
||||
"./rootHttpRouter": "./src/entrypoints/rootHttpRouter/index.ts",
|
||||
"./rootLifecycle": "./src/entrypoints/rootLifecycle/index.ts",
|
||||
"./rootLogger": "./src/entrypoints/rootLogger/index.ts",
|
||||
@@ -55,9 +55,6 @@
|
||||
"discovery": [
|
||||
"src/entrypoints/discovery/index.ts"
|
||||
],
|
||||
"health": [
|
||||
"src/entrypoints/health/index.ts"
|
||||
],
|
||||
"httpAuth": [
|
||||
"src/entrypoints/httpAuth/index.ts"
|
||||
],
|
||||
@@ -76,6 +73,9 @@
|
||||
"rootConfig": [
|
||||
"src/entrypoints/rootConfig/index.ts"
|
||||
],
|
||||
"rootHealth": [
|
||||
"src/entrypoints/rootHealth/index.ts"
|
||||
],
|
||||
"rootHttpRouter": [
|
||||
"src/entrypoints/rootHttpRouter/index.ts"
|
||||
],
|
||||
|
||||
@@ -24,13 +24,13 @@ import { authServiceFactory } from '@backstage/backend-defaults/auth';
|
||||
import { cacheServiceFactory } from '@backstage/backend-defaults/cache';
|
||||
import { databaseServiceFactory } from '@backstage/backend-defaults/database';
|
||||
import { discoveryServiceFactory } from '@backstage/backend-defaults/discovery';
|
||||
import { rootHealthServiceFactory } from './entrypoints/rootHealth';
|
||||
import { httpAuthServiceFactory } from '@backstage/backend-defaults/httpAuth';
|
||||
import { httpRouterServiceFactory } from '@backstage/backend-defaults/httpRouter';
|
||||
import { lifecycleServiceFactory } from '@backstage/backend-defaults/lifecycle';
|
||||
import { loggerServiceFactory } from '@backstage/backend-defaults/logger';
|
||||
import { permissionsServiceFactory } from '@backstage/backend-defaults/permissions';
|
||||
import { rootConfigServiceFactory } from '@backstage/backend-defaults/rootConfig';
|
||||
import { rootHealthServiceFactory } from '@backstage/backend-defaults/rootHealth';
|
||||
import { rootHttpRouterServiceFactory } from '@backstage/backend-defaults/rootHttpRouter';
|
||||
import { rootLifecycleServiceFactory } from '@backstage/backend-defaults/rootLifecycle';
|
||||
import { rootLoggerServiceFactory } from '@backstage/backend-defaults/rootLogger';
|
||||
@@ -51,6 +51,7 @@ export const defaultServiceFactories = [
|
||||
lifecycleServiceFactory(),
|
||||
loggerServiceFactory(),
|
||||
permissionsServiceFactory(),
|
||||
rootHealthServiceFactory(),
|
||||
rootHttpRouterServiceFactory(),
|
||||
rootLifecycleServiceFactory(),
|
||||
rootLoggerServiceFactory(),
|
||||
@@ -59,7 +60,6 @@ export const defaultServiceFactories = [
|
||||
userInfoServiceFactory(),
|
||||
urlReaderServiceFactory(),
|
||||
eventsServiceFactory(),
|
||||
rootHealthServiceFactory(),
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { healthServiceFactory } from './healthServiceFactory';
|
||||
export { rootHealthServiceFactory } from './rootHealthServiceFactory';
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
import { mockServices } from '@backstage/backend-test-utils';
|
||||
import { DefaultHealthService } from './healthServiceFactory';
|
||||
import { DefaultRootHealthService } from './rootHealthServiceFactory';
|
||||
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
@@ -16,10 +16,10 @@ import { DefaultHealthService } from './healthServiceFactory';
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
describe('DefaultHealthService', () => {
|
||||
describe('DefaultRootHealthService', () => {
|
||||
describe('readiness', () => {
|
||||
it(`should return a 500 response if the server hasn't started yet`, async () => {
|
||||
const service = new DefaultHealthService({
|
||||
const service = new DefaultRootHealthService({
|
||||
lifecycle: mockServices.rootLifecycle.mock(),
|
||||
});
|
||||
await expect(service.getReadiness()).resolves.toEqual({
|
||||
@@ -38,7 +38,7 @@ describe('DefaultHealthService', () => {
|
||||
fn => (mockServerStartedFn = fn),
|
||||
);
|
||||
|
||||
const service = new DefaultHealthService({
|
||||
const service = new DefaultRootHealthService({
|
||||
lifecycle,
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('DefaultHealthService', () => {
|
||||
fn => (mockServerStoppedFn = fn),
|
||||
);
|
||||
|
||||
const service = new DefaultHealthService({
|
||||
const service = new DefaultRootHealthService({
|
||||
lifecycle: mockServices.rootLifecycle.mock(),
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('DefaultHealthService', () => {
|
||||
|
||||
describe('liveness', () => {
|
||||
it('should return 200 if the server has started', async () => {
|
||||
const service = new DefaultHealthService({
|
||||
const service = new DefaultRootHealthService({
|
||||
lifecycle: mockServices.rootLifecycle.mock(),
|
||||
});
|
||||
|
||||
+4
-4
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
HealthService,
|
||||
RootHealthService,
|
||||
RootLifecycleService,
|
||||
coreServices,
|
||||
createServiceFactory,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
|
||||
/** @internal */
|
||||
export class DefaultHealthService implements HealthService {
|
||||
export class DefaultRootHealthService implements RootHealthService {
|
||||
#isRunning = false;
|
||||
|
||||
constructor(readonly options: { lifecycle: RootLifecycleService }) {
|
||||
@@ -53,12 +53,12 @@ export class DefaultHealthService implements HealthService {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const healthServiceFactory = createServiceFactory({
|
||||
export const rootHealthServiceFactory = createServiceFactory({
|
||||
service: coreServices.health,
|
||||
deps: {
|
||||
lifecycle: coreServices.rootLifecycle,
|
||||
},
|
||||
async factory({ lifecycle }) {
|
||||
return new DefaultHealthService({ lifecycle });
|
||||
return new DefaultRootHealthService({ lifecycle });
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { HealthService } from '@backstage/backend-plugin-api';
|
||||
import { RootHealthService } from '@backstage/backend-plugin-api';
|
||||
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
@@ -19,7 +19,7 @@ import { HealthService } from '@backstage/backend-plugin-api';
|
||||
import Router from 'express-promise-router';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
export function createHealthRouter(options: { health: HealthService }) {
|
||||
export function createHealthRouter(options: { health: RootHealthService }) {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
|
||||
+7
-1
@@ -17,7 +17,13 @@
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface HealthService {
|
||||
export interface RootHealthService {
|
||||
/**
|
||||
* Get the liveness status of the backend.
|
||||
*/
|
||||
getLiveness(): Promise<{ status: number; payload?: any }>;
|
||||
/**
|
||||
* Get the readiness status of the backend.
|
||||
*/
|
||||
getReadiness(): Promise<{ status: number; payload?: any }>;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export type {
|
||||
export type { RootConfigService } from './RootConfigService';
|
||||
export type { DatabaseService } from './DatabaseService';
|
||||
export type { DiscoveryService } from './DiscoveryService';
|
||||
export type { HealthService } from './HealthService';
|
||||
export type { RootHealthService } from './RootHealthService';
|
||||
export type {
|
||||
HttpRouterService,
|
||||
HttpRouterServiceAuthPolicy,
|
||||
|
||||
@@ -20,11 +20,11 @@ import {
|
||||
HostDiscovery,
|
||||
discoveryServiceFactory,
|
||||
} from '@backstage/backend-defaults/discovery';
|
||||
import { healthServiceFactory } from '@backstage/backend-defaults/health';
|
||||
import { httpRouterServiceFactory } from '@backstage/backend-defaults/httpRouter';
|
||||
import { lifecycleServiceFactory } from '@backstage/backend-defaults/lifecycle';
|
||||
import { loggerServiceFactory } from '@backstage/backend-defaults/logger';
|
||||
import { permissionsServiceFactory } from '@backstage/backend-defaults/permissions';
|
||||
import { rootHealthServiceFactory } from '@backstage/backend-defaults/rootHealth';
|
||||
import { rootHttpRouterServiceFactory } from '@backstage/backend-defaults/rootHttpRouter';
|
||||
import { rootLifecycleServiceFactory } from '@backstage/backend-defaults/rootLifecycle';
|
||||
import { schedulerServiceFactory } from '@backstage/backend-defaults/scheduler';
|
||||
@@ -345,8 +345,8 @@ export namespace mockServices {
|
||||
}));
|
||||
}
|
||||
|
||||
export namespace health {
|
||||
export const factory = healthServiceFactory;
|
||||
export namespace rootHealth {
|
||||
export const factory = rootHealthServiceFactory;
|
||||
export const mock = simpleMock(coreServices.health, () => ({
|
||||
getLiveness: jest.fn(),
|
||||
getReadiness: jest.fn(),
|
||||
|
||||
Reference in New Issue
Block a user