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:
parent
de7b95a691
commit
c0925ea75c
@ -3,6 +3,7 @@ import type {
|
|||||||
IFeatureToggleClient,
|
IFeatureToggleClient,
|
||||||
IFeatureToggleClientStore,
|
IFeatureToggleClientStore,
|
||||||
IFeatureToggleQuery,
|
IFeatureToggleQuery,
|
||||||
|
IFlagResolver,
|
||||||
} from '../../../types';
|
} from '../../../types';
|
||||||
import type { FeatureConfigurationClient } from '../../feature-toggle/types/feature-toggle-strategies-store-type';
|
import type { FeatureConfigurationClient } from '../../feature-toggle/types/feature-toggle-strategies-store-type';
|
||||||
import type ConfigurationRevisionService from '../../feature-toggle/configuration-revision-service';
|
import type ConfigurationRevisionService from '../../feature-toggle/configuration-revision-service';
|
||||||
@ -99,19 +100,23 @@ export class ClientFeatureToggleCache {
|
|||||||
|
|
||||||
private interval: NodeJS.Timer;
|
private interval: NodeJS.Timer;
|
||||||
|
|
||||||
|
private flagResolver: IFlagResolver;
|
||||||
|
|
||||||
private configurationRevisionService: ConfigurationRevisionService;
|
private configurationRevisionService: ConfigurationRevisionService;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
clientFeatureToggleStore: IFeatureToggleClientStore,
|
clientFeatureToggleStore: IFeatureToggleClientStore,
|
||||||
eventStore: IEventStore,
|
eventStore: IEventStore,
|
||||||
configurationRevisionService: ConfigurationRevisionService,
|
configurationRevisionService: ConfigurationRevisionService,
|
||||||
|
flagResolver: IFlagResolver,
|
||||||
) {
|
) {
|
||||||
this.eventStore = eventStore;
|
this.eventStore = eventStore;
|
||||||
this.configurationRevisionService = configurationRevisionService;
|
this.configurationRevisionService = configurationRevisionService;
|
||||||
this.clientFeatureToggleStore = clientFeatureToggleStore;
|
this.clientFeatureToggleStore = clientFeatureToggleStore;
|
||||||
|
this.flagResolver = flagResolver;
|
||||||
this.onUpdateRevisionEvent = this.onUpdateRevisionEvent.bind(this);
|
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(
|
this.configurationRevisionService.on(
|
||||||
UPDATE_REVISION,
|
UPDATE_REVISION,
|
||||||
this.onUpdateRevisionEvent,
|
this.onUpdateRevisionEvent,
|
||||||
@ -158,7 +163,9 @@ export class ClientFeatureToggleCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async onUpdateRevisionEvent() {
|
private async onUpdateRevisionEvent() {
|
||||||
await this.pollEvents();
|
if (this.flagResolver.isEnabled('deltaApi')) {
|
||||||
|
await this.pollEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pollEvents() {
|
public async pollEvents() {
|
||||||
|
@ -27,6 +27,7 @@ export const createClientFeatureToggleCache = (
|
|||||||
featureToggleClientStore,
|
featureToggleClientStore,
|
||||||
eventStore,
|
eventStore,
|
||||||
configurationRevisionService,
|
configurationRevisionService,
|
||||||
|
flagResolver,
|
||||||
);
|
);
|
||||||
|
|
||||||
return clientFeatureToggleCache;
|
return clientFeatureToggleCache;
|
||||||
|
Loading…
Reference in New Issue
Block a user