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,
|
"disableBulkToggle": false,
|
||||||
"disableMetrics": false,
|
"disableMetrics": false,
|
||||||
"disableNotifications": false,
|
"disableNotifications": false,
|
||||||
|
"disablePublishUnannouncedEvents": false,
|
||||||
|
"disableUpdateMaxRevisionId": false,
|
||||||
"edgeBulkMetrics": false,
|
"edgeBulkMetrics": false,
|
||||||
"embedProxy": true,
|
"embedProxy": true,
|
||||||
"embedProxyFrontend": true,
|
"embedProxyFrontend": true,
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'stream';
|
||||||
import { Logger } from '../../logger';
|
import { Logger } from '../../logger';
|
||||||
import { IEventStore, IUnleashConfig, IUnleashStores } from '../../types';
|
import {
|
||||||
|
IEventStore,
|
||||||
|
IFlagResolver,
|
||||||
|
IUnleashConfig,
|
||||||
|
IUnleashStores,
|
||||||
|
} from '../../types';
|
||||||
|
|
||||||
export const UPDATE_REVISION = 'UPDATE_REVISION';
|
export const UPDATE_REVISION = 'UPDATE_REVISION';
|
||||||
|
|
||||||
@ -11,13 +16,19 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
|||||||
|
|
||||||
private revisionId: number;
|
private revisionId: number;
|
||||||
|
|
||||||
|
private flagResolver: IFlagResolver;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
||||||
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
{
|
||||||
|
getLogger,
|
||||||
|
flagResolver,
|
||||||
|
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver'>,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.logger = getLogger('configuration-revision-service.ts');
|
this.logger = getLogger('configuration-revision-service.ts');
|
||||||
this.eventStore = eventStore;
|
this.eventStore = eventStore;
|
||||||
|
this.flagResolver = flagResolver;
|
||||||
this.revisionId = 0;
|
this.revisionId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +41,10 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateMaxRevisionId(): Promise<number> {
|
async updateMaxRevisionId(): Promise<number> {
|
||||||
|
if (this.flagResolver.isEnabled('disableUpdateMaxRevisionId')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const revisionId = await this.eventStore.getMaxRevisionId(
|
const revisionId = await this.eventStore.getMaxRevisionId(
|
||||||
this.revisionId,
|
this.revisionId,
|
||||||
);
|
);
|
||||||
|
@ -2,21 +2,32 @@ import { IUnleashConfig } from '../types/option';
|
|||||||
import { IUnleashStores } from '../types/stores';
|
import { IUnleashStores } from '../types/stores';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { IEventStore } from '../types/stores/event-store';
|
import { IEventStore } from '../types/stores/event-store';
|
||||||
|
import { IFlagResolver } from '../types';
|
||||||
|
|
||||||
export default class EventAnnouncer {
|
export default class EventAnnouncer {
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
|
|
||||||
private eventStore: IEventStore;
|
private eventStore: IEventStore;
|
||||||
|
|
||||||
|
private flagResolver: IFlagResolver;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
{ eventStore }: Pick<IUnleashStores, 'eventStore'>,
|
||||||
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
{
|
||||||
|
getLogger,
|
||||||
|
flagResolver,
|
||||||
|
}: Pick<IUnleashConfig, 'getLogger' | 'flagResolver'>,
|
||||||
) {
|
) {
|
||||||
this.logger = getLogger('services/event-service.ts');
|
this.logger = getLogger('services/event-service.ts');
|
||||||
|
this.flagResolver = flagResolver;
|
||||||
this.eventStore = eventStore;
|
this.eventStore = eventStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
async publishUnannouncedEvents(): Promise<void> {
|
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'
|
| 'collectTrafficDataUsage'
|
||||||
| 'useMemoizedActiveTokens'
|
| 'useMemoizedActiveTokens'
|
||||||
| 'userAccessUIEnabled'
|
| 'userAccessUIEnabled'
|
||||||
|
| 'disableUpdateMaxRevisionId'
|
||||||
|
| 'disablePublishUnannouncedEvents'
|
||||||
| 'sdkReporting';
|
| 'sdkReporting';
|
||||||
|
|
||||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||||
@ -247,6 +249,14 @@ const flags: IFlags = {
|
|||||||
process.env.UNLEASH_EXPERIMENTAL_USER_ACCESS_UI_ENABLED,
|
process.env.UNLEASH_EXPERIMENTAL_USER_ACCESS_UI_ENABLED,
|
||||||
false,
|
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 = {
|
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||||
|
Loading…
Reference in New Issue
Block a user