Skip to content

Commit

Permalink
chore: remove schedulers (#5895)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Jan 15, 2024
1 parent 1c84a81 commit 3e186f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -29,6 +29,7 @@ exports[`should create default config 1`] = `
"enabled": true,
"maxAge": 3600000,
},
"dailyMetricsStorageDays": 31,
"db": {
"acquireConnectionTimeout": 30000,
"applicationName": "unleash",
Expand Down
6 changes: 6 additions & 0 deletions src/lib/create-config.ts
Expand Up @@ -551,6 +551,11 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {

const feedbackUriPath = process.env.FEEDBACK_URI_PATH;

const dailyMetricsStorageDays = Math.min(
parseEnvVarNumber(process.env.DAILY_METRICS_STORAGE_DAYS, 31),
92,
);

return {
db,
session,
Expand Down Expand Up @@ -587,6 +592,7 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
metricsRateLimiting,
rateLimiting,
feedbackUriPath,
dailyMetricsStorageDays,
};
}

Expand Down
16 changes: 0 additions & 16 deletions src/lib/features/scheduler/schedule-services.ts
Expand Up @@ -145,22 +145,6 @@ export const scheduleServices = async (
'clearMetrics',
);

schedulerService.schedule(
() => {
clientMetricsServiceV2.clearDailyMetrics(92).catch(console.error);
},
hoursToMilliseconds(24),
'clearDailyMetrics',
);

schedulerService.schedule(
() => {
clientMetricsServiceV2.aggregateDailyMetrics().catch(console.error);
},
hoursToMilliseconds(24),
'aggregateDailyMetrics',
);

schedulerService.schedule(
accountService.updateLastSeen.bind(accountService),
minutesToMilliseconds(3),
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types/option.ts
Expand Up @@ -133,6 +133,7 @@ export interface IUnleashOptions {
publicFolder?: string;
disableScheduler?: boolean;
metricsRateLimiting?: Partial<IMetricsRateLimiting>;
dailyMetricsStorageDays?: number;
rateLimiting?: Partial<IRateLimiting>;
}

Expand Down Expand Up @@ -236,6 +237,7 @@ export interface IUnleashConfig {
segmentValuesLimit: number;
strategySegmentsLimit: number;
metricsRateLimiting: IMetricsRateLimiting;
dailyMetricsStorageDays: number;
clientFeatureCaching: IClientCachingOption;
accessControlMaxAge: number;
prometheusApi?: string;
Expand Down

0 comments on commit 3e186f1

Please sign in to comment.