Merge pull request #21728 from drodil/signals_plugin2
feat: signals plugins
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
"@backstage/plugin-search-react": "workspace:^",
|
||||
"@backstage/plugin-sentry": "workspace:^",
|
||||
"@backstage/plugin-shortcuts": "workspace:^",
|
||||
"@backstage/plugin-signals": "workspace:^",
|
||||
"@backstage/plugin-stack-overflow": "workspace:^",
|
||||
"@backstage/plugin-stackstorm": "workspace:^",
|
||||
"@backstage/plugin-tech-insights": "workspace:^",
|
||||
|
||||
@@ -19,3 +19,4 @@
|
||||
export { badgesPlugin } from '@backstage/plugin-badges';
|
||||
export { shortcutsPlugin } from '@backstage/plugin-shortcuts';
|
||||
export { homePlugin } from '@backstage/plugin-home';
|
||||
export { signalsPlugin } from '@backstage/plugin-signals';
|
||||
|
||||
@@ -72,6 +72,8 @@
|
||||
"@backstage/plugin-search-backend-module-techdocs": "workspace:^",
|
||||
"@backstage/plugin-search-backend-node": "workspace:^",
|
||||
"@backstage/plugin-search-common": "workspace:^",
|
||||
"@backstage/plugin-signals-backend": "workspace:^",
|
||||
"@backstage/plugin-signals-node": "workspace:^",
|
||||
"@backstage/plugin-tech-insights-backend": "workspace:^",
|
||||
"@backstage/plugin-tech-insights-backend-module-jsonfc": "workspace:^",
|
||||
"@backstage/plugin-tech-insights-node": "workspace:^",
|
||||
|
||||
@@ -26,19 +26,19 @@ import Router from 'express-promise-router';
|
||||
import {
|
||||
CacheManager,
|
||||
createServiceBuilder,
|
||||
DatabaseManager,
|
||||
getRootLogger,
|
||||
HostDiscovery,
|
||||
loadBackendConfig,
|
||||
notFoundHandler,
|
||||
DatabaseManager,
|
||||
HostDiscovery,
|
||||
ServerTokenManager,
|
||||
UrlReaders,
|
||||
useHotMemoize,
|
||||
ServerTokenManager,
|
||||
} from '@backstage/backend-common';
|
||||
import { TaskScheduler } from '@backstage/backend-tasks';
|
||||
import { Config } from '@backstage/config';
|
||||
import healthcheck from './plugins/healthcheck';
|
||||
import { metricsInit, metricsHandler } from './metrics';
|
||||
import { metricsHandler, metricsInit } from './metrics';
|
||||
import auth from './plugins/auth';
|
||||
import azureDevOps from './plugins/azure-devops';
|
||||
import catalog from './plugins/catalog';
|
||||
@@ -65,6 +65,7 @@ import lighthouse from './plugins/lighthouse';
|
||||
import linguist from './plugins/linguist';
|
||||
import devTools from './plugins/devtools';
|
||||
import nomad from './plugins/nomad';
|
||||
import signals from './plugins/signals';
|
||||
import { PluginEnvironment } from './types';
|
||||
import { ServerPermissionClient } from '@backstage/plugin-permission-node';
|
||||
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
|
||||
@@ -72,6 +73,7 @@ import { DefaultEventBroker } from '@backstage/plugin-events-backend';
|
||||
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
|
||||
import { MeterProvider } from '@opentelemetry/sdk-metrics';
|
||||
import { metrics } from '@opentelemetry/api';
|
||||
import { DefaultSignalService } from '@backstage/plugin-signals-node';
|
||||
|
||||
// Expose opentelemetry metrics using a Prometheus exporter on
|
||||
// http://localhost:9464/metrics . See prometheus.yml in packages/backend for
|
||||
@@ -98,6 +100,9 @@ function makeCreateEnv(config: Config) {
|
||||
});
|
||||
|
||||
const eventBroker = new DefaultEventBroker(root.child({ type: 'plugin' }));
|
||||
const signalService = DefaultSignalService.create({
|
||||
eventBroker,
|
||||
});
|
||||
|
||||
root.info(`Created UrlReader ${reader}`);
|
||||
|
||||
@@ -119,6 +124,7 @@ function makeCreateEnv(config: Config) {
|
||||
permissions,
|
||||
scheduler,
|
||||
identity,
|
||||
signalService,
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -172,6 +178,7 @@ async function main() {
|
||||
const linguistEnv = useHotMemoize(module, () => createEnv('linguist'));
|
||||
const devToolsEnv = useHotMemoize(module, () => createEnv('devtools'));
|
||||
const nomadEnv = useHotMemoize(module, () => createEnv('nomad'));
|
||||
const signalsEnv = useHotMemoize(module, () => createEnv('signals'));
|
||||
|
||||
const apiRouter = Router();
|
||||
apiRouter.use('/catalog', await catalog(catalogEnv));
|
||||
@@ -198,6 +205,7 @@ async function main() {
|
||||
apiRouter.use('/linguist', await linguist(linguistEnv));
|
||||
apiRouter.use('/devtools', await devTools(devToolsEnv));
|
||||
apiRouter.use('/nomad', await nomad(nomadEnv));
|
||||
apiRouter.use('/signals', await signals(signalsEnv));
|
||||
apiRouter.use(notFoundHandler());
|
||||
|
||||
await lighthouse(lighthouseEnv);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Router } from 'express';
|
||||
import { createRouter } from '@backstage/plugin-signals-backend';
|
||||
import { PluginEnvironment } from '../types';
|
||||
|
||||
export default async function createPlugin(
|
||||
env: PluginEnvironment,
|
||||
): Promise<Router> {
|
||||
return await createRouter({
|
||||
logger: env.logger,
|
||||
eventBroker: env.eventBroker,
|
||||
identity: env.identity,
|
||||
});
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import { PluginTaskScheduler } from '@backstage/backend-tasks';
|
||||
import { IdentityApi } from '@backstage/plugin-auth-node';
|
||||
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
||||
import { EventBroker } from '@backstage/plugin-events-node';
|
||||
import { DefaultSignalService } from '@backstage/plugin-signals-node';
|
||||
|
||||
export type PluginEnvironment = {
|
||||
logger: Logger;
|
||||
@@ -40,4 +41,5 @@ export type PluginEnvironment = {
|
||||
scheduler: PluginTaskScheduler;
|
||||
identity: IdentityApi;
|
||||
eventBroker: EventBroker;
|
||||
signalService: DefaultSignalService;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user