Commit 8774dbb7 authored by Sean McGivern's avatar Sean McGivern

Use Flipper 0.21.0

This allows us to remove a custom patch that has now been accepted
upstream.
parent 4696e416
......@@ -488,9 +488,9 @@ gem 'google-protobuf', '~> 3.15.8'
gem 'toml-rb', '~> 1.0.0'
# Feature toggles
gem 'flipper', '~> 0.17.1'
gem 'flipper-active_record', '~> 0.17.1'
gem 'flipper-active_support_cache_store', '~> 0.17.1'
gem 'flipper', '~> 0.21.0'
gem 'flipper-active_record', '~> 0.21.0'
gem 'flipper-active_support_cache_store', '~> 0.21.0'
gem 'unleash', '~> 0.1.5'
gem 'gitlab-experiment', '~> 0.5.4'
......
......@@ -372,13 +372,13 @@ GEM
rake
ffi-yajl (2.3.4)
libyajl2 (~> 1.2)
flipper (0.17.1)
flipper-active_record (0.17.1)
activerecord (>= 4.2, < 7)
flipper (~> 0.17.1)
flipper-active_support_cache_store (0.17.1)
activesupport (>= 4.2, < 7)
flipper (~> 0.17.1)
flipper (0.21.0)
flipper-active_record (0.21.0)
activerecord (>= 5.0, < 7)
flipper (~> 0.21.0)
flipper-active_support_cache_store (0.21.0)
activesupport (>= 5.0, < 7)
flipper (~> 0.21.0)
flowdock (0.7.1)
httparty (~> 0.7)
multi_json
......@@ -1454,9 +1454,9 @@ DEPENDENCIES
faraday_middleware-aws-sigv4 (~> 0.3.0)
fast_blank
ffaker (~> 2.10)
flipper (~> 0.17.1)
flipper-active_record (~> 0.17.1)
flipper-active_support_cache_store (~> 0.17.1)
flipper (~> 0.21.0)
flipper-active_record (~> 0.21.0)
flipper-active_support_cache_store (~> 0.21.0)
flowdock (~> 0.7)
fog-aliyun (~> 0.3)
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
superclass.table_name = 'feature_gates'
end
# To enable EE overrides
class ActiveSupportCacheStoreAdapter < Flipper::Adapters::ActiveSupportCacheStore
end
InvalidFeatureFlagError = Class.new(Exception) # rubocop:disable Lint/InheritException
class << self
......@@ -167,7 +171,8 @@ class Feature
ActiveSupportCacheStoreAdapter.new(
active_record_adapter,
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
# 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