Update flipper to 0.11.0 and take advantage of the new features
- Added an ActiveSupport (using Rails.cache) caching adapter - Overview of the new features can be found at https://johnnunemaker.com/flippin-features-at-runtime/ - Full Changelog can be found at https://github.com/jnunemaker/flipper/blob/v0.11.0/Changelog.md Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
54c2d7bdbd
commit
b51e6d6ddc
4 changed files with 32 additions and 20 deletions
5
Gemfile
5
Gemfile
|
@ -405,8 +405,9 @@ gem 'gitaly-proto', '~> 0.59.0', require: 'gitaly'
|
|||
gem 'toml-rb', '~> 0.3.15', require: false
|
||||
|
||||
# Feature toggles
|
||||
gem 'flipper', '~> 0.10.2'
|
||||
gem 'flipper-active_record', '~> 0.10.2'
|
||||
gem 'flipper', '~> 0.11.0'
|
||||
gem 'flipper-active_record', '~> 0.11.0'
|
||||
gem 'flipper-active_support_cache_store', '~> 0.11.0'
|
||||
|
||||
# Structured logging
|
||||
gem 'lograge', '~> 0.5'
|
||||
|
|
14
Gemfile.lock
14
Gemfile.lock
|
@ -215,10 +215,13 @@ GEM
|
|||
path_expander (~> 1.0)
|
||||
ruby_parser (~> 3.0)
|
||||
sexp_processor (~> 4.0)
|
||||
flipper (0.10.2)
|
||||
flipper-active_record (0.10.2)
|
||||
flipper (0.11.0)
|
||||
flipper-active_record (0.11.0)
|
||||
activerecord (>= 3.2, < 6)
|
||||
flipper (~> 0.10.2)
|
||||
flipper (~> 0.11.0)
|
||||
flipper-active_support_cache_store (0.11.0)
|
||||
activesupport (>= 3.2, < 6)
|
||||
flipper (~> 0.11.0)
|
||||
flowdock (0.7.1)
|
||||
httparty (~> 0.7)
|
||||
multi_json
|
||||
|
@ -1021,8 +1024,9 @@ DEPENDENCIES
|
|||
faraday (~> 0.12)
|
||||
ffaker (~> 2.4)
|
||||
flay (~> 2.8.0)
|
||||
flipper (~> 0.10.2)
|
||||
flipper-active_record (~> 0.10.2)
|
||||
flipper (~> 0.11.0)
|
||||
flipper-active_record (~> 0.11.0)
|
||||
flipper-active_support_cache_store (~> 0.11.0)
|
||||
fog-aliyun (~> 0.2.0)
|
||||
fog-aws (~> 1.4)
|
||||
fog-core (~> 1.44)
|
||||
|
|
|
@ -1,8 +1,22 @@
|
|||
require 'flipper/middleware/memoizer'
|
||||
require 'flipper/adapters/active_record'
|
||||
require 'flipper/adapters/active_support_cache_store'
|
||||
|
||||
Flipper.configure do |config|
|
||||
config.default do
|
||||
adapter = Flipper::Adapters::ActiveRecord.new(
|
||||
feature_class: Feature::FlipperFeature, gate_class: Feature::FlipperGate)
|
||||
cached_adapter = Flipper::Adapters::ActiveSupportCacheStore.new(
|
||||
adapter,
|
||||
Rails.cache,
|
||||
expires_in: 10.seconds)
|
||||
|
||||
Flipper.new(cached_adapter)
|
||||
end
|
||||
end
|
||||
|
||||
Feature.register_feature_groups
|
||||
|
||||
unless Rails.env.test?
|
||||
Rails.application.config.middleware.use Flipper::Middleware::Memoizer,
|
||||
lambda { Feature.flipper }
|
||||
|
||||
Feature.register_feature_groups
|
||||
require 'flipper/middleware/memoizer'
|
||||
Rails.application.config.middleware.use Flipper::Middleware::Memoizer
|
||||
end
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'flipper/adapters/active_record'
|
||||
|
||||
class Feature
|
||||
# Classes to override flipper table names
|
||||
class FlipperFeature < Flipper::Adapters::ActiveRecord::Feature
|
||||
|
@ -62,12 +60,7 @@ class Feature
|
|||
end
|
||||
|
||||
def flipper
|
||||
@flipper ||= begin
|
||||
adapter = Flipper::Adapters::ActiveRecord.new(
|
||||
feature_class: FlipperFeature, gate_class: FlipperGate)
|
||||
|
||||
Flipper.new(adapter)
|
||||
end
|
||||
@flipper ||= Flipper.instance
|
||||
end
|
||||
|
||||
# This method is called from config/initializers/flipper.rb and can be used
|
||||
|
|
Loading…
Reference in a new issue