1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: do not initialize cache when flag is off (#8969)

This feature is still in early alpha. We do not want to populate any
cache on startup. We might not want to do it ever.
This commit is contained in:
Jaanus Sellin 2024-12-12 15:06:33 +02:00 committed by GitHub
parent de7b95a691
commit c0925ea75c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import type {
IFeatureToggleClient,
IFeatureToggleClientStore,
IFeatureToggleQuery,
IFlagResolver,
} from '../../../types';
import type { FeatureConfigurationClient } from '../../feature-toggle/types/feature-toggle-strategies-store-type';
import type ConfigurationRevisionService from '../../feature-toggle/configuration-revision-service';
@ -99,19 +100,23 @@ export class ClientFeatureToggleCache {
private interval: NodeJS.Timer;
private flagResolver: IFlagResolver;
private configurationRevisionService: ConfigurationRevisionService;
constructor(
clientFeatureToggleStore: IFeatureToggleClientStore,
eventStore: IEventStore,
configurationRevisionService: ConfigurationRevisionService,
flagResolver: IFlagResolver,
) {
this.eventStore = eventStore;
this.configurationRevisionService = configurationRevisionService;
this.clientFeatureToggleStore = clientFeatureToggleStore;
this.flagResolver = flagResolver;
this.onUpdateRevisionEvent = this.onUpdateRevisionEvent.bind(this);
this.initCache();
// this.initCache(); TODO: we dont want to initialize cache on startup, but ondemand in future?
this.configurationRevisionService.on(
UPDATE_REVISION,
this.onUpdateRevisionEvent,
@ -158,8 +163,10 @@ export class ClientFeatureToggleCache {
}
private async onUpdateRevisionEvent() {
if (this.flagResolver.isEnabled('deltaApi')) {
await this.pollEvents();
}
}
public async pollEvents() {
const latestRevision =

View File

@ -27,6 +27,7 @@ export const createClientFeatureToggleCache = (
featureToggleClientStore,
eventStore,
configurationRevisionService,
flagResolver,
);
return clientFeatureToggleCache;