mirror of
https://github.com/jbranchaud/til
synced 2026-08-31 16:51:46 +00:00
Add Flipper Discards Actors When Feature Fully Enabled as a Rails TIL
This commit is contained in:
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||
|
||||
_1822 TILs and counting..._
|
||||
_1823 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -1180,6 +1180,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Filter ActiveStorage Blobs To Only Images](rails/filter-active-storage-blobs-to-only-images.md)
|
||||
- [Find Or Create A Record With FactoryBot](rails/find-or-create-a-record-with-factory-bot.md)
|
||||
- [Find Records With Multiple Associated Records](rails/find-records-with-multiple-associated-records.md)
|
||||
- [Flipper Discards Actors When Feature Fully Enabled](rails/flipper-discards-actors-when-feature-fully-enabled.md)
|
||||
- [Force All Users To Sign Out](rails/force-all-users-to-sign-out.md)
|
||||
- [Format DateTime With Builtin Formats](rails/format-datetime-with-builtin-formats.md)
|
||||
- [Format Specific html.erb Template Files](rails/format-specific-html-erb-template-files.md)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Flipper Discards Actors When Feature Fully Enabled
|
||||
|
||||
Let's say I have a Flipper feature flag that I have enabled for a handful of
|
||||
users. When I eventully go to globally enable that feature flag with the big
|
||||
green 'Enable' button, the gate short-circuit evalutes to true everywhere. This
|
||||
is what grants access to anyone when it is enabled.
|
||||
|
||||
There is another thing that happens under the hood when the switch is flipped.
|
||||
All those individual actor records I created for that feature flag get wiped
|
||||
out.
|
||||
|
||||
In the ideal case, that's not an issue because the flag is fully on going
|
||||
forward. But what about the scenario where I need to rollback the feature
|
||||
release.
|
||||
|
||||
What if I'm thinking, "whoops, my team isn't ready to handle the influx of users
|
||||
for this feature, I want to go back to having it partially enabled for that
|
||||
small list of users for now."
|
||||
|
||||
I'll be out of luck because that list of _actors_ was cleared. So if I'm
|
||||
anticipating that I might want to be able to rollback in that way, I should
|
||||
capture a snapshot of the set of actors I had enabled for that feature.
|
||||
|
||||
```ruby
|
||||
actors = Flipper[:some_feature].actors_value.to_a
|
||||
puts JSON.pretty_generate(actors)
|
||||
```
|
||||
|
||||
I could then iterate through that list making calls to individually enable it
|
||||
for each actor:
|
||||
|
||||
```ruby
|
||||
Flipper.enable_actor(:some_feature, Flipper::Actor.new(flipper_id))
|
||||
```
|
||||
|
||||
I give a full example of what that script could look like in [Rollback a Flipper Feature Flag Release](https://www.visualmode.dev/rollback-a-flipper-feature-flag-release).
|
||||
Reference in New Issue
Block a user