use default schedule for collator modules and make schedule option opotional
Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
@@ -385,21 +385,15 @@ import { searchModuleCatalogCollator } from '@backstage/plugin-search-backend-mo
|
||||
import { searchModuleTechDocsCollator } from '@backstage/plugin-search-backend-module-techdocs/alpha';
|
||||
import { searchModuleExploreCollator } from '@backstage/plugin-search-backend-module-explore/alpha';
|
||||
|
||||
const schedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
|
||||
const backend = createBackend();
|
||||
// adding the search plugin to the backend
|
||||
backend.add(searchPlugin());
|
||||
// (optional) the default search engine is Lunr, if you want to extend the search backend with another search engine.
|
||||
backend.add(searchModuleElasticsearchEngine());
|
||||
// extending search with collator modules to start index documents
|
||||
backend.add(searchModuleCatalogCollator({ schedule }));
|
||||
backend.add(searchModuleTechDocsCollator({ schedule }));
|
||||
backend.add(searchModuleExploreCollator({ schedule }));
|
||||
// extending search with collator modules to start index documents, take in optional schedule parameters.
|
||||
backend.add(searchModuleCatalogCollator());
|
||||
backend.add(searchModuleTechDocsCollator());
|
||||
backend.add(searchModuleExploreCollator());
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
@@ -40,14 +40,9 @@ backend.add(catalogPlugin());
|
||||
backend.add(catalogModuleTemplateKind());
|
||||
|
||||
// Search
|
||||
const schedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
backend.add(searchPlugin());
|
||||
backend.add(searchModuleCatalogCollator({ schedule }));
|
||||
backend.add(searchModuleTechDocsCollator({ schedule }));
|
||||
backend.add(searchModuleExploreCollator({ schedule }));
|
||||
backend.add(searchModuleCatalogCollator());
|
||||
backend.add(searchModuleTechDocsCollator());
|
||||
backend.add(searchModuleExploreCollator());
|
||||
|
||||
backend.start();
|
||||
|
||||
@@ -46,7 +46,7 @@ export type SearchModuleCatalogCollatorOptions = Omit<
|
||||
DefaultCatalogCollatorFactoryOptions,
|
||||
'discovery' | 'tokenManager'
|
||||
> & {
|
||||
schedule: TaskScheduleDefinition;
|
||||
schedule?: TaskScheduleDefinition;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ export type SearchModuleCatalogCollatorOptions = Omit<
|
||||
* Search backend module for the Catalog index.
|
||||
*/
|
||||
export const searchModuleCatalogCollator = createBackendModule(
|
||||
(options: SearchModuleCatalogCollatorOptions) => ({
|
||||
(options?: SearchModuleCatalogCollatorOptions) => ({
|
||||
moduleId: 'catalogCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
@@ -73,12 +73,18 @@ export const searchModuleCatalogCollator = createBackendModule(
|
||||
scheduler,
|
||||
indexRegistry,
|
||||
}) {
|
||||
const { schedule, ...rest } = options;
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(schedule),
|
||||
schedule: scheduler.createScheduledTaskRunner(
|
||||
options?.schedule ?? defaultSchedule,
|
||||
),
|
||||
factory: DefaultCatalogCollatorFactory.fromConfig(config, {
|
||||
...rest,
|
||||
...options,
|
||||
discovery,
|
||||
tokenManager,
|
||||
}),
|
||||
|
||||
@@ -47,7 +47,7 @@ export type SearchModuleExploreCollatorOptions = Omit<
|
||||
ToolDocumentCollatorFactoryOptions,
|
||||
'logger' | 'discovery'
|
||||
> & {
|
||||
schedule: TaskScheduleDefinition;
|
||||
schedule?: TaskScheduleDefinition;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ export type SearchModuleExploreCollatorOptions = Omit<
|
||||
* Search backend module for the Explore index.
|
||||
*/
|
||||
export const searchModuleExploreCollator = createBackendModule(
|
||||
(options: SearchModuleExploreCollatorOptions) => ({
|
||||
(options?: SearchModuleExploreCollatorOptions) => ({
|
||||
moduleId: 'exploreCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
@@ -68,12 +68,18 @@ export const searchModuleExploreCollator = createBackendModule(
|
||||
indexRegistry: searchIndexRegistryExtensionPoint,
|
||||
},
|
||||
async init({ config, logger, discovery, scheduler, indexRegistry }) {
|
||||
const { schedule, ...rest } = options;
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(schedule),
|
||||
schedule: scheduler.createScheduledTaskRunner(
|
||||
options?.schedule ?? defaultSchedule,
|
||||
),
|
||||
factory: ToolDocumentCollatorFactory.fromConfig(config, {
|
||||
...rest,
|
||||
...options,
|
||||
discovery,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
}),
|
||||
|
||||
@@ -42,7 +42,7 @@ export type SearchModuleTechDocsCollatorOptions = Omit<
|
||||
TechDocsCollatorFactoryOptions,
|
||||
'logger' | 'discovery' | 'tokenManager'
|
||||
> & {
|
||||
schedule: TaskScheduleDefinition;
|
||||
schedule?: TaskScheduleDefinition;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ export type SearchModuleTechDocsCollatorOptions = Omit<
|
||||
* Search backend module for the TechDocs index.
|
||||
*/
|
||||
export const searchModuleTechDocsCollator = createBackendModule(
|
||||
(options: SearchModuleTechDocsCollatorOptions) => ({
|
||||
(options?: SearchModuleTechDocsCollatorOptions) => ({
|
||||
moduleId: 'techDocsCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
@@ -71,12 +71,18 @@ export const searchModuleTechDocsCollator = createBackendModule(
|
||||
scheduler,
|
||||
indexRegistry,
|
||||
}) {
|
||||
const { schedule, ...rest } = options;
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(schedule),
|
||||
schedule: scheduler.createScheduledTaskRunner(
|
||||
options?.schedule ?? defaultSchedule,
|
||||
),
|
||||
factory: DefaultTechDocsCollatorFactory.fromConfig(config, {
|
||||
...rest,
|
||||
...options,
|
||||
discovery,
|
||||
tokenManager,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
|
||||
Reference in New Issue
Block a user