Skip to content

Add the idea of a regular throttle

Nick Thomas requested to merge 337829-deduplicate-regular-throttles into master

What does this MR do and why?

In my MR to add another throttle (!70310 (merged)), I'm hitting a Rubocop Metrics/AbcSize error in Gitlab::RackAttack.configure_throttles , which is the proximate cause of this refactoring.

Currently we have three throttles that are exactly copy-pastes of each other. I'm about to add a fourth, and the web throttle can become a fifth once a couple of columns in the application_settings table are renamed.

To avoid further copy-pasting in what is becoming a popular area of the codebase, I add a "regular throttle" abstraction that lets us just add the throttle fragment / name to an array and get this functionality for free.

Irregular throttles can still be added, but if we can make a throttle regular, we should, to aid us in future refactorings.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #337829 (closed)

Edited by Nick Thomas

Merge request reports