clean up comments and dependencies

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
Co-authored-by: Camila Loiola <camilaibs@gmail.com>
This commit is contained in:
Emma Indal
2023-03-06 10:35:24 +01:00
committed by Camila Belo
parent bf54977e68
commit 1a79af33f2
7 changed files with 98 additions and 61 deletions
+5
View File
@@ -25,10 +25,15 @@
"clean": "backstage-cli package clean"
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/plugin-app-backend": "workspace:^",
"@backstage/plugin-catalog-backend": "workspace:^",
"@backstage/plugin-explore-backend": "workspace:^",
"@backstage/plugin-scaffolder-backend": "workspace:^",
"@backstage/plugin-search-backend": "workspace:^",
"@backstage/plugin-search-backend-node": "workspace:^",
"@backstage/plugin-techdocs-backend": "workspace:^",
"@backstage/plugin-todo-backend": "workspace:^"
},
+1 -59
View File
@@ -21,56 +21,7 @@ import { appPlugin } from '@backstage/plugin-app-backend/alpha';
import { todoPlugin } from '@backstage/plugin-todo-backend';
import { techdocsPlugin } from '@backstage/plugin-techdocs-backend/alpha';
import { searchPlugin } from '@backstage/plugin-search-backend';
import { elasticSearchEngineModule } from '@backstage/plugin-search-backend-module-elasticsearch';
import {
coreServices,
createBackendModule,
} from '@backstage/backend-plugin-api';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node';
import { DefaultCatalogCollatorFactory } from '@backstage/plugin-catalog-backend';
// import { pgSearchEngineModule } from '@backstage/plugin-search-backend-module-pg';
// import { lunrSearchEngineModule } from '@backstage/plugin-search-backend-node/';
// TODO: move to search-backend-node?
export const searchIndexRegistry = createBackendModule({
moduleId: 'searchIndexRegistry',
pluginId: 'search',
register(env) {
env.registerInit({
deps: {
indexRegistry: searchIndexRegistryExtensionPoint,
config: coreServices.config,
discovery: coreServices.discovery,
tokenManager: coreServices.tokenManager,
logger: coreServices.logger,
scheduler: coreServices.scheduler,
},
async init({
indexRegistry,
config,
discovery,
tokenManager,
scheduler,
}) {
const schedule = scheduler.createScheduledTaskRunner({
frequency: { minutes: 10 },
timeout: { minutes: 15 },
// A 3 second delay gives the backend server a chance to initialize before
// any collators are executed, which may attempt requests against the API.
initialDelay: { seconds: 3 },
});
indexRegistry.addCollator({
schedule,
factory: DefaultCatalogCollatorFactory.fromConfig(config, {
discovery: discovery,
tokenManager: tokenManager,
}),
});
},
});
},
});
import { searchIndexRegistry } from './plugins/search';
const backend = createBackend();
@@ -81,15 +32,6 @@ backend.add(todoPlugin());
backend.add(techdocsPlugin());
backend.add(searchPlugin());
// just as example of search engine module, remove before shipping and use default
backend.add(
elasticSearchEngineModule({
indexTemplate: {
name: 'my-custom-template',
body: { index_patterns: ['*index*'], template: {} },
},
}),
);
backend.add(searchIndexRegistry());
backend.start();
@@ -0,0 +1,82 @@
/*
* 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 {
coreServices,
createBackendModule,
} from '@backstage/backend-plugin-api';
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node';
import { DefaultCatalogCollatorFactory } from '@backstage/plugin-catalog-backend';
import { DefaultTechDocsCollatorFactory } from '@backstage/plugin-techdocs-backend';
import { ToolDocumentCollatorFactory } from '@backstage/plugin-explore-backend';
import { loggerToWinstonLogger } from '@backstage/backend-common';
export const searchIndexRegistry = createBackendModule({
moduleId: 'searchIndexRegistry',
pluginId: 'search',
register(env) {
env.registerInit({
deps: {
indexRegistry: searchIndexRegistryExtensionPoint,
config: coreServices.config,
discovery: coreServices.discovery,
tokenManager: coreServices.tokenManager,
logger: coreServices.logger,
scheduler: coreServices.scheduler,
},
async init({
indexRegistry,
config,
logger,
discovery,
tokenManager,
scheduler,
}) {
const schedule = scheduler.createScheduledTaskRunner({
frequency: { minutes: 10 },
timeout: { minutes: 15 },
// A 3 second delay gives the backend server a chance to initialize before
// any collators are executed, which may attempt requests against the API.
initialDelay: { seconds: 3 },
});
indexRegistry.addCollator({
schedule,
factory: DefaultCatalogCollatorFactory.fromConfig(config, {
discovery,
tokenManager,
}),
});
indexRegistry.addCollator({
schedule,
factory: DefaultTechDocsCollatorFactory.fromConfig(config, {
discovery,
logger: loggerToWinstonLogger(logger),
tokenManager,
}),
});
indexRegistry.addCollator({
schedule,
factory: ToolDocumentCollatorFactory.fromConfig(config, {
discovery,
logger: loggerToWinstonLogger(logger),
}),
});
},
});
},
});
@@ -23,6 +23,8 @@
"clean": "backstage-cli package clean"
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/plugin-search-backend-node": "workspace:^",
"@backstage/plugin-search-common": "workspace:^",
@@ -557,7 +557,7 @@ export const elasticSearchEngineModule = createBackendModule(
searchEngine.setTranslator(options.translator);
}
// set custom index template if available TODO(emmaindal): make it possible to pass in mutliple index templates
// set custom index template if available
if (options?.indexTemplate) {
searchEngine.setIndexTemplate(options.indexTemplate);
}
+1 -1
View File
@@ -117,7 +117,7 @@ export const searchPlugin = createBackendPlugin({
engine: searchEngine,
types: searchIndexBuilder.getDocumentTypes(),
});
// We register the router with the http service.
http.use(router);
},
});
+6
View File
@@ -7773,6 +7773,7 @@ __metadata:
resolution: "@backstage/plugin-search-backend-module-elasticsearch@workspace:plugins/search-backend-module-elasticsearch"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/config": "workspace:^"
"@backstage/plugin-search-backend-node": "workspace:^"
@@ -22481,11 +22482,16 @@ __metadata:
version: 0.0.0-use.local
resolution: "example-backend-next@workspace:packages/backend-next"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-defaults": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/plugin-app-backend": "workspace:^"
"@backstage/plugin-catalog-backend": "workspace:^"
"@backstage/plugin-explore-backend": "workspace:^"
"@backstage/plugin-scaffolder-backend": "workspace:^"
"@backstage/plugin-search-backend": "workspace:^"
"@backstage/plugin-search-backend-node": "workspace:^"
"@backstage/plugin-techdocs-backend": "workspace:^"
"@backstage/plugin-todo-backend": "workspace:^"
languageName: unknown