Merge pull request #10668 from colinux/fix-flipper-strict

Tech: initialise vraiment les nouveaux feature flags
This commit is contained in:
Colin Darie 2024-07-31 15:01:38 +00:00 committed by GitHub
commit 665289f7d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 23 deletions

View file

@ -174,7 +174,7 @@ GEM
clamav-client (3.2.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.3.1)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
content_disposition (1.0.0)
crack (1.0.0)
@ -234,7 +234,7 @@ GEM
dumb_delegator (1.0.0)
email_validator (2.2.4)
activemodel
erubi (1.12.0)
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
ethon (0.16.0)
@ -252,19 +252,20 @@ GEM
faraday-net_http (3.1.0)
net-http
ffi (1.16.3)
flipper (1.2.2)
flipper (1.3.0)
concurrent-ruby (< 2)
flipper-active_record (1.2.2)
flipper-active_record (1.3.0)
activerecord (>= 4.2, < 8)
flipper (~> 1.2.2)
flipper-active_support_cache_store (1.2.2)
flipper (~> 1.3.0)
flipper-active_support_cache_store (1.3.0)
activesupport (>= 4.2, < 8)
flipper (~> 1.2.2)
flipper-ui (1.2.2)
flipper (~> 1.3.0)
flipper-ui (1.3.0)
erubi (>= 1.0.0, < 2.0.0)
flipper (~> 1.2.2)
flipper (~> 1.3.0)
rack (>= 1.4, < 4)
rack-protection (>= 1.5.3, <= 4.0.0)
rack-protection (>= 1.5.3, < 5.0.0)
rack-session (>= 1.0.2, < 3.0.0)
sanitize (< 7)
fog-core (2.4.0)
builder
@ -509,7 +510,7 @@ GEM
pundit (2.3.1)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.0)
racc (1.8.1)
rack (2.2.9)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
@ -527,6 +528,8 @@ GEM
rack (~> 2.2, >= 2.2.4)
rack-proxy (0.7.7)
rack
rack-session (1.0.2)
rack (< 3)
rack-test (2.1.0)
rack (>= 1.3)
rack_session_access (0.2.0)
@ -677,7 +680,7 @@ GEM
nokogiri (>= 1.6.2)
rexml
xmlenc (>= 0.7.1)
sanitize (6.1.0)
sanitize (6.1.2)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sass (3.7.4)

View file

@ -6,7 +6,7 @@ require 'flipper/adapters/active_record'
require 'flipper/adapters/active_support_cache_store'
def setup_features(features)
existing = Flipper.preload(features).map { _1.name.to_sym }
existing = Flipper.preload_all.map { _1.name.to_sym }
missing = features - existing
missing.each do |feature|
@ -41,23 +41,24 @@ rescue ActiveRecord::ConnectionNotEstablished, ActiveRecord::NoDatabaseError, PG
false
end
Flipper.configure do |config|
config.adapter do
Flipper::Adapters::ActiveSupportCacheStore.new(
Flipper::Adapters::ActiveRecord.new,
ActiveSupport::Cache::MemoryStore.new,
10.seconds
)
end
end
ActiveSupport.on_load(:active_record) do
if database_exists? && ActiveRecord::Base.connection.data_source_exists?('flipper_features')
setup_features(features)
end
end
Flipper.configure do |config|
config.adapter do
Flipper::Adapters::ActiveSupportCacheStore.new(
Flipper::Adapters::ActiveRecord.new,
ActiveSupport::Cache::MemoryStore.new,
expires_in: 10.seconds
)
end
end
Rails.application.configure do
config.flipper.actor_limit = 500 # default is 100 but hide_instructeur_email feature has ~478
# don't preload features for /assets/* but do for everything else
config.flipper.preload = -> (request) { !request.path.start_with?('/assets/', '/ping') }
config.flipper.strict = Rails.env.development?