mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
chore: adds killswitch to scheduled per sec caches (#6291)
## About the changes Adds killswitches to update revision id and publish unpublished events
This commit is contained in:
parent
c7182d8faf
commit
869e33138b
@ -85,6 +85,8 @@ exports[`should create default config 1`] = `
|
||||
"disableBulkToggle": false,
|
||||
"disableMetrics": false,
|
||||
"disableNotifications": false,
|
||||
"disablePublishUnannouncedEvents": false,
|
||||
"disableUpdateMaxRevisionId": false,
|
||||
"edgeBulkMetrics": false,
|
||||
"embedProxy": true,
|
||||
"embedProxyFrontend": true,
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { EventEmitter } from 'stream';
|
||||
import { Logger } from '../../logger';
|
||||
import { IEventStore, IUnleashConfig, IUnleashStores } from '../../types';
|
||||
import {
|
||||
IEventStore,
|
||||
IFlagResolver,
|
||||
IUnleashConfig,
|
||||
IUnleashStores,
|
||||
} from '../../types';
|
||||
|
||||
export const UPDATE_REVISION = 'UPDATE_REVISION';
|
||||
|
||||
@ -11,13 +16,19 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
|
||||
private revisionId: number;
|
||||
|
||||
private flagResolver: IFlagResolver;
|
||||
|
||||
constructor(
|
||||
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
||||
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
||||
{
|
||||
getLogger,
|
||||
flagResolver,
|
||||
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver'>,
|
||||
) {
|
||||
super();
|
||||
this.logger = getLogger('configuration-revision-service.ts');
|
||||
this.eventStore = eventStore;
|
||||
this.flagResolver = flagResolver;
|
||||
this.revisionId = 0;
|
||||
}
|
||||
|
||||
@ -30,6 +41,10 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
}
|
||||
|
||||
async updateMaxRevisionId(): Promise<number> {
|
||||
if (this.flagResolver.isEnabled('disableUpdateMaxRevisionId')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const revisionId = await this.eventStore.getMaxRevisionId(
|
||||
this.revisionId,
|
||||
);
|
||||
|
@ -2,21 +2,32 @@ import { IUnleashConfig } from '../types/option';
|
||||
import { IUnleashStores } from '../types/stores';
|
||||
import { Logger } from '../logger';
|
||||
import { IEventStore } from '../types/stores/event-store';
|
||||
import { IFlagResolver } from '../types';
|
||||
|
||||
export default class EventAnnouncer {
|
||||
private logger: Logger;
|
||||
|
||||
private eventStore: IEventStore;
|
||||
|
||||
private flagResolver: IFlagResolver;
|
||||
|
||||
constructor(
|
||||
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
||||
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
||||
{
|
||||
getLogger,
|
||||
flagResolver,
|
||||
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver'>,
|
||||
) {
|
||||
this.logger = getLogger('services/event-service.ts');
|
||||
this.flagResolver = flagResolver;
|
||||
this.eventStore = eventStore;
|
||||
}
|
||||
|
||||
async publishUnannouncedEvents(): Promise<void> {
|
||||
return this.eventStore.publishUnannouncedEvents();
|
||||
if (this.flagResolver.isEnabled('disablePublishUnannouncedEvents')) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return this.eventStore.publishUnannouncedEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ export type IFlagKey =
|
||||
| 'collectTrafficDataUsage'
|
||||
| 'useMemoizedActiveTokens'
|
||||
| 'userAccessUIEnabled'
|
||||
| 'disableUpdateMaxRevisionId'
|
||||
| 'disablePublishUnannouncedEvents'
|
||||
| 'sdkReporting';
|
||||
|
||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||
@ -247,6 +249,14 @@ const flags: IFlags = {
|
||||
process.env.UNLEASH_EXPERIMENTAL_USER_ACCESS_UI_ENABLED,
|
||||
false,
|
||||
),
|
||||
disableUpdateMaxRevisionId: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_DISABLE_SCHEDULED_CACHES,
|
||||
false,
|
||||
),
|
||||
disablePublishUnannouncedEvents: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_DISABLE_SCHEDULED_CACHES,
|
||||
false,
|
||||
),
|
||||
};
|
||||
|
||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||
|
Loading…
Reference in New Issue
Block a user