mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: allow you to use the options object to override *all* the new resource limits (#7938)
This allows us to use different limits for enterprise self-hosted and hosted
This commit is contained in:
		
							parent
							
								
									40b06dabb6
								
							
						
					
					
						commit
						3cd312f9a9
					
				@ -657,41 +657,56 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
 | 
			
		||||
            1,
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_FEATURE_ENVIRONMENT_STRATEGIES_LIMIT,
 | 
			
		||||
                30,
 | 
			
		||||
                options?.resourceLimits?.featureEnvironmentStrategies ?? 30,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        constraintValues: Math.max(
 | 
			
		||||
            1,
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_CONSTRAINT_VALUES_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.constraintValues || 250,
 | 
			
		||||
                options?.resourceLimits?.constraintValues ?? 250,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        constraints: Math.max(
 | 
			
		||||
            0,
 | 
			
		||||
            parseEnvVarNumber(process.env.UNLEASH_CONSTRAINTS_LIMIT, 30),
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_CONSTRAINTS_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.constraints ?? 30,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        environments: parseEnvVarNumber(
 | 
			
		||||
            process.env.UNLEASH_ENVIRONMENTS_LIMIT,
 | 
			
		||||
            50,
 | 
			
		||||
        environments: Math.max(
 | 
			
		||||
            1,
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_ENVIRONMENTS_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.environments ?? 50,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        projects: Math.max(
 | 
			
		||||
            1,
 | 
			
		||||
            parseEnvVarNumber(process.env.UNLEASH_PROJECTS_LIMIT, 500),
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_PROJECTS_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.projects ?? 500,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        apiTokens: Math.max(
 | 
			
		||||
            0,
 | 
			
		||||
            parseEnvVarNumber(process.env.UNLEASH_API_TOKENS_LIMIT, 2000),
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_API_TOKENS_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.apiTokens ?? 2000,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        segments: Math.max(
 | 
			
		||||
            0,
 | 
			
		||||
            parseEnvVarNumber(process.env.UNLEASH_SEGMENTS_LIMIT, 300),
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_SEGMENTS_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.segments ?? 300,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
        featureFlags: Math.max(
 | 
			
		||||
            1,
 | 
			
		||||
            parseEnvVarNumber(
 | 
			
		||||
                process.env.UNLEASH_FEATURE_FLAGS_LIMIT,
 | 
			
		||||
                options?.resourceLimits?.featureFlags || 5000,
 | 
			
		||||
                options?.resourceLimits?.featureFlags ?? 5000,
 | 
			
		||||
            ),
 | 
			
		||||
        ),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
@ -144,7 +144,17 @@ export interface IUnleashOptions {
 | 
			
		||||
    dailyMetricsStorageDays?: number;
 | 
			
		||||
    rateLimiting?: Partial<IRateLimiting>;
 | 
			
		||||
    resourceLimits?: Partial<
 | 
			
		||||
        Pick<ResourceLimitsSchema, 'constraintValues' | 'featureFlags'>
 | 
			
		||||
        Pick<
 | 
			
		||||
            ResourceLimitsSchema,
 | 
			
		||||
            | 'apiTokens'
 | 
			
		||||
            | 'constraintValues'
 | 
			
		||||
            | 'constraints'
 | 
			
		||||
            | 'environments'
 | 
			
		||||
            | 'featureEnvironmentStrategies'
 | 
			
		||||
            | 'featureFlags'
 | 
			
		||||
            | 'projects'
 | 
			
		||||
            | 'segments'
 | 
			
		||||
        >
 | 
			
		||||
    >;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user