protected RateLimitedFunctionBase(FunctionBaseDecorator funcBase, Func <object[], Task <bool> > ignoreRateLimitFunc) { _funcBase = funcBase; _ignoreRateLimitFunc = ignoreRateLimitFunc; _funcBase.BeforeExecution += (sender, objects) => BeforeExecution?.Invoke(sender, objects); _funcBase.AfterExecution += (sender, o) => AfterExecution?.Invoke(sender, o); _funcBase.ExecutionDelayed += (sender, objects) => ExecutionDelayed?.Invoke(sender, objects); }
protected ConcurrentFunctionBase(FunctionBaseDecorator funcBase, int maxConcurrency) { _funcBase = funcBase; _semaphoreSlim = new SemaphoreSlim(maxConcurrency); _funcBase.BeforeExecution += (sender, objects) => BeforeExecution?.Invoke(sender, objects); _funcBase.AfterExecution += (sender, objects) => AfterExecution?.Invoke(sender, objects); _funcBase.ExecutionDelayed += (sender, objects) => ExecutionDelayed?.Invoke(sender, objects); }
protected WeightRateLimitedFunctionBase(FunctionBaseDecorator func, int weight, WeightRateLimitedFunctionConfiguration configuration, Func <object[], Task <bool> > ignoreRateLimitFunc) : base(func, ignoreRateLimitFunc) { _weight = weight; _configuration = configuration; // ReSharper disable once VirtualMemberCallInConstructor BeforeExecution += BeforeExecutionHandler; // ReSharper disable once VirtualMemberCallInConstructor ExecutionDelayed += ExecutionCanceledHandler; }
protected RetryFunctionBase(FunctionBaseDecorator funcBase, int maxRetryCount, Func <object, bool> retryOnResult, Func <Exception, bool> retryOnException) { _funcBase = funcBase; _maxRetryCount = maxRetryCount; _retryOnResult = retryOnResult; _retryOnException = retryOnException; _funcBase.BeforeExecution += (sender, objects) => BeforeExecution?.Invoke(sender, objects); _funcBase.AfterExecution += (sender, objects) => AfterExecution?.Invoke(sender, objects); _funcBase.ExecutionDelayed += (sender, objects) => ExecutionDelayed?.Invoke(sender, objects); }
protected TimeRateLimitedFunctionBase(FunctionBaseDecorator func, TimeSpan minInterval, Func <object[], Task <bool> > ignoreRateLimitFunc) : base(func, ignoreRateLimitFunc) { MinInterval = minInterval; _lastExecution = DateTime.MinValue; func.BeforeExecution += BeforeExecutionHandler; func.ExecutionDelayed += ExecutionDelayedHandler; // ReSharper disable once VirtualMemberCallInConstructor ExecutionDelayed += ExecutionDelayedHandler; }
public TimeRateLimitedFunction(FunctionBaseDecorator func, TimeSpan minAllowedInterval, Func <bool> doNotRateLimitWhen) : base(func, minAllowedInterval, async args => await Task.FromResult(doNotRateLimitWhen())) { }
public TimeRateLimitedFunction(FunctionBaseDecorator func, TimeSpan minAllowedInterval) : base(func, minAllowedInterval) { }
protected TimeRateLimitedFunctionBase(FunctionBaseDecorator func, TimeSpan minInterval) : this(func, minInterval, args => Task.FromResult(false)) { }
public AsyncTimeRateLimitedFunction(FunctionBaseDecorator func, TimeSpan minAllowedInterval, Func <Task <bool> > doNotRateLimitWhen) : base(func, minAllowedInterval, async args => await doNotRateLimitWhen()) { }
public AsyncConcurrentFunction(FunctionBaseDecorator func, int maxConcurrency) : base(func, maxConcurrency) { }
public AsyncWeightRateLimitedFunction(FunctionBaseDecorator func, int weight, WeightRateLimitedFunctionConfiguration configuration, Func <Task <bool> > doNotRateLimitWhen) : base(func, weight, configuration, async args => await doNotRateLimitWhen()) { }
public AsyncWeightRateLimitedFunction(FunctionBaseDecorator func, int weight, WeightRateLimitedFunctionConfiguration configuration) : base(func, weight, configuration) { }
public WeightRateLimitedFunction(FunctionBaseDecorator func, int weight, WeightRateLimitedFunctionConfiguration configuration, Func <bool> doNotRateLimitWhen) : base(func, weight, configuration, async args => await Task.FromResult(doNotRateLimitWhen())) { }
protected WeightRateLimitedFunctionBase(FunctionBaseDecorator func, int weight, WeightRateLimitedFunctionConfiguration configuration) : this(func, weight, configuration, args => Task.FromResult(false)) { }
public AsyncRetryFunction(FunctionBaseDecorator func, int maxRetryCount, Func <T, bool> retryOnResult, Func <Exception, bool> retryOnException) : base(func, maxRetryCount, arg => retryOnResult((T)arg), retryOnException) { }