{flipper}
intro & use
101
Why a feature switch?
# reasons
limited early access
incremental rollout
coordination
opt-in features
maintenance and emergency stop flag
experiments
sunsetting
Features
PostgreSQL based
Relying on ActiveRecord
1.
2.
Global, per user & group switching
3.
Integrated UI
Can work on its own, no cloud subscription required
# 101
PostgreSQL based
# backend
All switches are stored in a table
Environment specific
Global switch (aka 0/1, On/Off)
# global
if Flipper.enabled?(:doge)
# such feature
else
# very quiet
end
User / actor
# actor
Any object responding to flipper_id
flipper_id: User;5
flipper_id:
DEB3D850-39FB-444B-A1E9-404A990FDBE0
default
custom
User / actor
user = User.first
# Check if enabled without an actor
Flipper.enabled?(:verbose_logging) # false
# Check if enabled for the given user
Flipper.enabled?(:verbose_logging, user) # false
# actor
User / actor: turning on / off
user = User.first
# enable
Flipper.enable_actor(:verbose_logging, user)
# disable
Flipper.disable_actor(:verbose_logging, user)
# actor
but that's rails console, we don't need that
Group: what we want
# definition in the flipper initializer
Flipper.register(:admins) do |actor, context|
actor.respond_to?(:admin?) && actor.admin?
end
# feature check
user = User.where(admin: false).first # user who returns false for admin?
Flipper.enabled?(:documentation, user) # false
admin = User.where(admin: true).first # user who returns true for admin?
Flipper.enabled?(:documentation, admin) # true
# groups
block based target definition
flipper-ui
# Flipper UI
/flipper
flipper-ui
# Flipper UI
/flipper access control
Rails.application.routes.draw do
# ..
constraints CanAccessFlipperUI do
mount Flipper::UI.app(Flipper) => "/flipper"
end
# ..
end
# well, that's not Meta
class CanAccessFlipperUI
def self.matches?(request)
request.env["warden"].user&.team&.root?
end
end
flipper-ui
# Flipper UI
configuring a feature
expressions
#! BONUS
power feature to look into
# define the property
must_be_21 = Flipper.property(:age).gte(21)
# enable a feature for with property as condition
Flipper.enable :night_club, must_be_21
# Under age
Flipper.enabled? :night_club, User.new(age: 18) #=> false
# Of age
Flipper.enabled? :night_club, User.new(age: 21) #=> true
# Combining
over_21 = Flipper.property(:age).gte(21)
paid = Flipper.property(:paid).eq(true)
vip = Flipper.property(:vip).eq(true)
Flipper.enable :night_club, Flipper.all(over_21, Flipper.any(paid, vip))
https://www.flippercloud.io/docs/features/expressions
flipper ui presentation
By Thomas Riboulet
flipper ui presentation
- 13