Merge pull request #4515 from backstage/iameap/search-indexer

[Search] Foundation: plugins and types
This commit is contained in:
Eric Peterson
2021-03-25 13:15:33 +01:00
committed by GitHub
42 changed files with 1152 additions and 22 deletions
+2
View File
@@ -41,6 +41,8 @@
"@backstage/plugin-proxy-backend": "^0.2.6",
"@backstage/plugin-rollbar-backend": "^0.1.8",
"@backstage/plugin-scaffolder-backend": "^0.9.2",
"@backstage/plugin-search-backend": "^0.1.1",
"@backstage/plugin-search-backend-node": "^0.1.1",
"@backstage/plugin-techdocs-backend": "^0.6.5",
"@backstage/plugin-todo-backend": "^0.1.1",
"@gitbeaker/node": "^28.0.2",
+3
View File
@@ -42,6 +42,7 @@ import kafka from './plugins/kafka';
import rollbar from './plugins/rollbar';
import scaffolder from './plugins/scaffolder';
import proxy from './plugins/proxy';
import search from './plugins/search';
import techdocs from './plugins/techdocs';
import todo from './plugins/todo';
import graphql from './plugins/graphql';
@@ -78,6 +79,7 @@ async function main() {
const authEnv = useHotMemoize(module, () => createEnv('auth'));
const proxyEnv = useHotMemoize(module, () => createEnv('proxy'));
const rollbarEnv = useHotMemoize(module, () => createEnv('rollbar'));
const searchEnv = useHotMemoize(module, () => createEnv('search'));
const techdocsEnv = useHotMemoize(module, () => createEnv('techdocs'));
const todoEnv = useHotMemoize(module, () => createEnv('todo'));
const kubernetesEnv = useHotMemoize(module, () => createEnv('kubernetes'));
@@ -91,6 +93,7 @@ async function main() {
apiRouter.use('/rollbar', await rollbar(rollbarEnv));
apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv));
apiRouter.use('/auth', await auth(authEnv));
apiRouter.use('/search', await search(searchEnv));
apiRouter.use('/techdocs', await techdocs(techdocsEnv));
apiRouter.use('/todo', await todo(todoEnv));
apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv));
+43
View File
@@ -0,0 +1,43 @@
/*
* Copyright 2021 Spotify AB
*
* 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 { useHotCleanup } from '@backstage/backend-common';
import { createRouter } from '@backstage/plugin-search-backend';
import { IndexBuilder } from '@backstage/plugin-search-backend-node';
import { PluginEnvironment } from '../types';
import { DefaultCatalogCollator } from '@backstage/plugin-catalog-backend';
export default async function createPlugin({
logger,
discovery,
}: PluginEnvironment) {
const indexBuilder = new IndexBuilder({ logger });
indexBuilder.addCollator({
type: 'software-catalog',
defaultRefreshIntervalSeconds: 600,
collator: new DefaultCatalogCollator(discovery),
});
// TODO: Move refresh loop logic into the builder.
const timerId = setInterval(() => {
indexBuilder.build();
}, 60000);
useHotCleanup(module, () => clearInterval(timerId));
return await createRouter({
logger,
});
}