Commit fd7b3032 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'flipper-0-21-0' into 'master'

Use Flipper 0.21.0

See merge request gitlab-org/gitlab!62688
parents 74c1c237 8774dbb7
...@@ -489,9 +489,9 @@ gem 'google-protobuf', '~> 3.17.1' ...@@ -489,9 +489,9 @@ gem 'google-protobuf', '~> 3.17.1'
gem 'toml-rb', '~> 1.0.0' gem 'toml-rb', '~> 1.0.0'
# Feature toggles # Feature toggles
gem 'flipper', '~> 0.17.1' gem 'flipper', '~> 0.21.0'
gem 'flipper-active_record', '~> 0.17.1' gem 'flipper-active_record', '~> 0.21.0'
gem 'flipper-active_support_cache_store', '~> 0.17.1' gem 'flipper-active_support_cache_store', '~> 0.21.0'
gem 'unleash', '~> 0.1.5' gem 'unleash', '~> 0.1.5'
gem 'gitlab-experiment', '~> 0.5.4' gem 'gitlab-experiment', '~> 0.5.4'
......
...@@ -376,13 +376,13 @@ GEM ...@@ -376,13 +376,13 @@ GEM
rake rake
ffi-yajl (2.3.4) ffi-yajl (2.3.4)
libyajl2 (~> 1.2) libyajl2 (~> 1.2)
flipper (0.17.1) flipper (0.21.0)
flipper-active_record (0.17.1) flipper-active_record (0.21.0)
activerecord (>= 4.2, < 7) activerecord (>= 5.0, < 7)
flipper (~> 0.17.1) flipper (~> 0.21.0)
flipper-active_support_cache_store (0.17.1) flipper-active_support_cache_store (0.21.0)
activesupport (>= 4.2, < 7) activesupport (>= 5.0, < 7)
flipper (~> 0.17.1) flipper (~> 0.21.0)
flowdock (0.7.1) flowdock (0.7.1)
httparty (~> 0.7) httparty (~> 0.7)
multi_json multi_json
...@@ -1453,9 +1453,9 @@ DEPENDENCIES ...@@ -1453,9 +1453,9 @@ DEPENDENCIES
faraday_middleware-aws-sigv4 (~> 0.3.0) faraday_middleware-aws-sigv4 (~> 0.3.0)
fast_blank fast_blank
ffaker (~> 2.10) ffaker (~> 2.10)
flipper (~> 0.17.1) flipper (~> 0.21.0)
flipper-active_record (~> 0.17.1) flipper-active_record (~> 0.21.0)
flipper-active_support_cache_store (~> 0.17.1) flipper-active_support_cache_store (~> 0.21.0)
flowdock (~> 0.7) flowdock (~> 0.7)
fog-aliyun (~> 0.3) fog-aliyun (~> 0.3)
fog-aws (~> 3.9) fog-aws (~> 3.9)
......
# frozen_string_literal: true
Rails.application.configure do
config.flipper.preload = false
config.flipper.memoizer = false
end
...@@ -18,6 +18,10 @@ class Feature ...@@ -18,6 +18,10 @@ class Feature
superclass.table_name = 'feature_gates' superclass.table_name = 'feature_gates'
end end
# To enable EE overrides
class ActiveSupportCacheStoreAdapter < Flipper::Adapters::ActiveSupportCacheStore
end
InvalidFeatureFlagError = Class.new(Exception) # rubocop:disable Lint/InheritException InvalidFeatureFlagError = Class.new(Exception) # rubocop:disable Lint/InheritException
class << self class << self
...@@ -167,7 +171,8 @@ class Feature ...@@ -167,7 +171,8 @@ class Feature
ActiveSupportCacheStoreAdapter.new( ActiveSupportCacheStoreAdapter.new(
active_record_adapter, active_record_adapter,
l2_cache_backend, l2_cache_backend,
expires_in: 1.hour) expires_in: 1.hour,
write_through: true)
# Thread-local L1 cache: use a short timeout since we don't have a # Thread-local L1 cache: use a short timeout since we don't have a
# way to expire this cache all at once # way to expire this cache all at once
......
# frozen_string_literal: true
# rubocop:disable Gitlab/NamespacedClass
# This class was already nested this way before moving to a separate file
class Feature
class ActiveSupportCacheStoreAdapter < Flipper::Adapters::ActiveSupportCacheStore
# This patch represents https://github.com/jnunemaker/flipper/pull/512. In
# Flipper 0.21.0 and later, we can remove this and just pass `write_through:
# true` to the constructor in `Feature.build_flipper_instance`.
extend ::Gitlab::Utils::Override
override :enable
def enable(feature, gate, thing)
result = @adapter.enable(feature, gate, thing)
@cache.write(key_for(feature.key), @adapter.get(feature), @write_options)
result
end
override :disable
def disable(feature, gate, thing)
result = @adapter.disable(feature, gate, thing)
@cache.write(key_for(feature.key), @adapter.get(feature), @write_options)
result
end
override :remove
def remove(feature)
result = @adapter.remove(feature)
@cache.delete(FeaturesKey)
@cache.write(key_for(feature.key), {}, @write_options)
result
end
end
end
# rubocop:disable Gitlab/NamespacedClass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment