Skip to content

Introduce an :instance scope for feature flags

What does this MR do and why?

The merge request introduces a new scope for feature flags called :instance. This scope allows feature flags to be enabled or disabled for the current GitLab instance, rather than for the current request or specific actors.

Note that setting a flag with the "percentage of actors" strategy won't work as expected with this scope since the flipper ID is always the same.

Usage

Feature.enaled?(:my_feature, :isntance)

Additional improvement

This MR also allows to pass :request or :current_request as actor to Feature.enabled? / Feature.disabled? (instead of passing Feature.current_request).

# Before you'd pass Feature.current_request
Feature.enaled?(:my_feature, Feature.current_request)

# After you can also pass `:request` or `:current_request`
Feature.enaled?(:my_feature, :request)
Feature.enaled?(:my_feature, :current_request)

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 #426093 (closed), #221042

Edited by Rémy Coutable

Merge request reports

Loading