1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#
# Usage:
# # if you want it to not reload and be really fast
# bin/rackup examples/api/memoized.ru -p 9999
#
# # if you want reloading
# bin/shotgun examples/api/memoized.ru -p 9999
#
# http://localhost:9999/
#
require 'bundler/setup'
require "active_support/notifications"
require "flipper/api"
require "flipper/adapters/pstore"
Flipper.configure do |config|
config.adapter {
Flipper::Adapters::Instrumented.new(
Flipper::Adapters::PStore.new,
instrumenter: ActiveSupport::Notifications,
)
}
end
ActiveSupport::Notifications.subscribe(/.*/, ->(*args) {
name, start, finish, id, data = args
case name
when "adapter_operation.flipper"
p data[:adapter_name] => data[:operation]
end
})
Flipper.register(:admins) { |actor|
actor.respond_to?(:admin?) && actor.admin?
}
# You can uncomment this to get some default data:
# Flipper.enable :logging
run Flipper::Api.app { |builder|
builder.use Flipper::Middleware::Memoizer, preload: true
}
|