move refresh loop to builder and use configured refreshInterval

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
Emma Indal
2021-04-23 15:03:32 +02:00
parent 039dbb4e20
commit cdda9c671d
2 changed files with 21 additions and 23 deletions
+1 -6
View File
@@ -13,7 +13,6 @@
* 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,
@@ -35,11 +34,7 @@ export default async function createPlugin({
collator: new DefaultCatalogCollator(discovery),
});
// TODO: Move refresh loop logic into the builder.
const timerId = setInterval(() => {
indexBuilder.build();
}, 60000);
useHotCleanup(module, () => clearInterval(timerId));
indexBuilder.build();
return await createRouter({
engine: indexBuilder.getSearchEngine(),