@@ -19,14 +19,30 @@ import { EntityProvider } from '@backstage/plugin-catalog-node';
|
||||
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
|
||||
import { Router } from 'express';
|
||||
import { PluginEnvironment } from '../types';
|
||||
import { GithubEntityProvider } from '@backstage/plugin-catalog-backend-module-github';
|
||||
|
||||
export default async function createPlugin(
|
||||
env: PluginEnvironment,
|
||||
providers?: Array<EntityProvider>,
|
||||
): Promise<Router> {
|
||||
const builder = await CatalogBuilder.create(env);
|
||||
const githubEntityProviders = GithubEntityProvider.fromConfig(env.config, {
|
||||
logger: env.logger,
|
||||
// optional: alternatively, use scheduler with schedule defined in app-config.yaml
|
||||
schedule: env.scheduler.createScheduledTaskRunner({
|
||||
frequency: { minutes: 5 },
|
||||
timeout: { minutes: 3 },
|
||||
}),
|
||||
scheduler: env.scheduler,
|
||||
});
|
||||
builder.addEntityProvider(githubEntityProviders);
|
||||
builder.addProcessor(new ScaffolderEntitiesProcessor());
|
||||
builder.addEntityProvider(providers ?? []);
|
||||
// const conflictBroker = new InMemoryEventBroker(env.logger);
|
||||
// conflictBroker.subscribe(
|
||||
// new ConflictEventSubscriber(env.logger, ['conflicts']),
|
||||
// );
|
||||
// builder.setConflictEventBroker(conflictBroker);
|
||||
const { processingEngine, router } = await builder.build();
|
||||
await processingEngine.start();
|
||||
return router;
|
||||
|
||||
@@ -167,6 +167,9 @@ export class CatalogBuilder {
|
||||
export type CatalogCollatorEntityTransformer =
|
||||
CatalogCollatorEntityTransformer_2;
|
||||
|
||||
// @public (undocumented)
|
||||
export const catalogConflictsTopic = 'catalog.conflict';
|
||||
|
||||
// @public (undocumented)
|
||||
export type CatalogEnvironment = {
|
||||
logger: Logger;
|
||||
|
||||
@@ -46,6 +46,7 @@ import { updateUnprocessedEntity } from './operations/refreshState/updateUnproce
|
||||
import { generateStableHash } from './util';
|
||||
import { EventBroker } from '@backstage/plugin-events-node';
|
||||
import { DateTime } from 'luxon';
|
||||
import { catalogConflictsTopic } from '../service';
|
||||
|
||||
// The number of items that are sent per batch to the database layer, when
|
||||
// doing .batchInsert calls to knex. This needs to be low enough to not cause
|
||||
@@ -361,7 +362,7 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
|
||||
);
|
||||
if (this.options.eventBroker) {
|
||||
await this.options.eventBroker?.publish({
|
||||
topic: 'catalog.conflicts',
|
||||
topic: catalogConflictsTopic,
|
||||
eventPayload: {
|
||||
entity,
|
||||
entityRef,
|
||||
|
||||
@@ -118,6 +118,9 @@ export type CatalogEnvironment = {
|
||||
permissions: PermissionEvaluator | PermissionAuthorizer;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export const catalogConflictsTopic = 'catalog.conflict';
|
||||
|
||||
/**
|
||||
* A builder that helps wire up all of the component parts of the catalog.
|
||||
*
|
||||
|
||||
@@ -18,4 +18,4 @@ export type {
|
||||
CatalogEnvironment,
|
||||
CatalogPermissionRuleInput,
|
||||
} from './CatalogBuilder';
|
||||
export { CatalogBuilder } from './CatalogBuilder';
|
||||
export { CatalogBuilder, catalogConflictsTopic } from './CatalogBuilder';
|
||||
|
||||
Reference in New Issue
Block a user