public async override Task Invoke(AspectContext context, AspectDelegate next) { string functionCode = context.ImplementationMethod.GetFunctionCode(); IAppContext appContext = context.ServiceProvider.GetRequiredService <IAppContext>(); string contextValue = appContext.GetValue(ContextKey)?.ToString(); var throttleCode = new ThrottleCode { ContextKind = ContextKey, FunctionCode = functionCode, ContextValue = contextValue }; var throttleValue = new ThrottleValue(); var throttleService = context.ServiceProvider.GetRequiredService <IThrottleService>(); if (await throttleService.ShouldPass(throttleCode, throttleValue)) { await next.Invoke(context); } else { throw new ApplicationException("Throttle limited."); } }
public static void CustomJobServiceStart(string configPath, ThrottleValue throttleValue = ThrottleValue.Medium) { UpdateOverdriveConfig(OverdriveJobType.Custom, configPath, (int)throttleValue); }