Skip to content

Commit

Permalink
Merge pull request #10668 from colinux/fix-flipper-strict
Browse files Browse the repository at this point in the history
Tech: initialise vraiment les nouveaux feature flags
  • Loading branch information
colinux authored Jul 31, 2024
2 parents 90e6c8a + 99fd12b commit 665289f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
27 changes: 15 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 9 additions & 8 deletions config/initializers/flipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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|
Expand Down Expand Up @@ -41,23 +41,24 @@ def database_exists?
false
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
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

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?
Expand Down

0 comments on commit 665289f

Please sign in to comment.