Why hello you dapper feature flagger!
Wait... what? Didn't I just email you a few days ago?
WHY YES I DID.
Awesome things are happening and I just want to Flipper.enable(:shout_from_rooftop, me)
about them!
Today I have another BOGO deal for you -- 0.27 and 0.28.
0.27 - Import (๐ฅ) and Export (๐ค)
Flipper has long had Flipper.import(other_flipper)
, but now it also has Flipper.export
!
Even cooler is that the UI now supports exporting and importing a backup. So now anytime you want, you can click export to download a backup file of all your features and their data.
Then, if you need to you can upload that file right back and restore all that feature data.
I bet you feel safer already! Probably upgraded while reading this and you've already exported 3 backups you wily programmer you.
If you are the only one who hasn't at this point, update flipper and click on "Settings" from the Flipper UI. You'll get a page like the one below.
From here you can download an export or upload one.
API
I also snuck in a new endpoint for import in Flipper::Api
and a corresponding use of it in the http adapter (which Cloud uses). This means that importing from OSS to Cloud is now a single HTTP request instead of many. Yay!
Of course this goodness works from code or a console. But I thought it was neat to drop it in the UI as well. Cloud will accept these export files soon as well.
0.28 - Multiple Actors (๐จโ๐ฉโ๐งโ๐ฆ)
BUT WAIT! THERE IS MORE! 0.28 is a feature and performance improvement all wrapped up in one tiny ๐.
A common feature flag idiom is to check multiple types of actors to see if a feature is enabled. This gives you control to release things at a few levels in your app.
For example, on Box Out we often check the user
, team
and org
to see if a feature is enabled. Before, we'd have to do something like:
if [user, user.team, user.org].any? { |actor| Flipper.enabled?(:my_feature, actor) }
# do something
end
This worked ok, but it was slower (3 > 1) and changed the probability odds for % of actors (explained below).
Now, you can pass multiple actors:
Flipper.enabled?(:my_feature, user, user.team, user.org)
Or an array of actors:
Flipper.enabled?(:my_feature, [user, user.team, user.org])
Slick, eh?
This is the principle of fewer & faster. Doing one feature check means fewer calls to instrumentation (and subscribers) and non-actor gates (like boolean and % of time).
Additionally, the algorithm for consistently rolling out a feature to a % of actors now factors in all actors. This means if you enable 50% of actors and always pass in user
, user.team
and user.org
, then only 50% of that full combination is enabled, rather than 50% of users + 50% of teams + 50% of orgs (which would total up to a lot higher than 50%).
On my laptop, passing in multiple actors is about 2.5x faster for 3 actors:
bundle exec ruby benchmark/enabled_multiple_actors_ips.rb
Calculating -------------------------------------
with array of actors 144.002k (ยฑ 0.6%) i/s - 731.952k in 5.083089s
with multiple enabled? checks
57.018k (ยฑ 0.4%) i/s - 290.496k in 5.094918s
Comparison:
with array of actors: 144001.9 i/s
with multiple enabled? checks: 57017.9 i/s - 2.53x slower
And 5x faster for 8 actors (source):
bundle exec ruby benchmark/enabled_multiple_actors_ips.rb
Calculating -------------------------------------
with array of actors 108.559k (ยฑ 1.0%) i/s - 546.150k in 5.031447s
with multiple enabled? checks
21.972k (ยฑ 0.4%) i/s - 110.250k in 5.017841s
Comparison:
with array of actors: 108558.8 i/s
with multiple enabled? checks: 21971.9 i/s - 4.94x slower
Between the improvements in 0.26.x and 0.28, Flipper.enabled?
is now swimmingly (๐) fast.
I highly recommend upgrading to 0.28. Please let me know if you have any issues and I hope you have a great day!