-
Notifications
You must be signed in to change notification settings - Fork 0
Initial Feature Flag system #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jazairi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great foundation to get away from FlipFlip! I'm especially impressed with the documentation, which is thorough and easy to follow.
I noted a small typo and raised a question about the use of define_singleton_method. I'm not yet requesting a change on the latter, but I wanted to confirm the intention behind using that instead of define_method.
app/helpers/features_helper.rb
Outdated
| # Predefine convenience methods for each valid feature | ||
| # Allows for direct calls like feature_geodata? | ||
| Feature::VALID_FEATURES.each do |name| | ||
| define_singleton_method("feature_#{name}?") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this creates methods on the module itself, rather than instances. Is that the intended behavior? I.e., in the views, do we want to call if FeaturesHelper.feature_geodata? or if feature_geodata??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was aiming for if feature_geodata?... I think this works that way but haven't checked in views. If it requires the full call then I think just ditching the Helper and using Feature.enabled?(:geodata) will be simpler. Let me confirm if it works the way I think it does and you can let me know if the intended syntax feels good or if we should just keep it simple and go with always using the model functions and ditch the Helper regardless :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed it works like I wanted (still open to ditching it entirely and just using views):
Example of what this allows
<% if @suggestions.present? && !feature_geodata? %>Example of just ditching the Helper entirely:
<% if @suggestions.present? && !Feature.enabled?(:geodata) %>I like the first but am worried that the inconsistency between how we call feature flags in Views vs Models may leads to us forgetting about the shorthand and always using the model version and not the helper over time 🤷🏻♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative that I still sort of like (this doesn't work with this code but would be easy to swap to if we like it better):
<% if @suggestions.present? && !geodata_enabled? %>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it works because it's falling back to method_missing, not using the predefined convenience methods. For example, modifying shared/_site_title like so renders the GeoData site title:
<% if FeaturesHelper.feature_geodata? %>
<h2>Search for geospatial/GIS data</h2>
<p id="site-desc">Find GIS data held at MIT and other institutions</p>
<% else %>
<h2>Search the MIT Libraries</h2>
<% end %>It also works as expected using Feature.enabled?(:geodata) and feature_geodata?, which I think are the two feature-flipping methods we want. However, if we remove this bit of code at the end of the helper, Feature.enabled?(:geodata) and feature_geodata? still work, but FeaturesHelper.feature_geodata? doesn't.
I'm still not sure I fully understand the intent, though, so a synchronous chat might be helpful!
jazairi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in Slack, I'd like to propose removing the dynamic feature flag handling provided by FeaturesHelper. I'm open to retaining it, though, and I'll leave that call to you. If we do decide to retain it, let's remove lines 48-52 to avoid confusion.
app/models/feature.rb
Outdated
| # # In models/controllers: | ||
| # return unless Feature.enabled?(:geodata) | ||
| # | ||
| # # In views (using FeaturesHelper): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh, this mentions the helper that no longer exists.. I'll fixup the words and not just the example :)
jazairi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for talking through this!
Why are these changes being introduced: * FlipFlip has not been maintained in years and we believe it is causing more problems than it is solving. We need a simpler, more maintainable feature flag system. * Our needs are simple: we need to be able to turn features on and off based on environment variables. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-77 How does this address that need: * Created a simple Feature model that reads from environment variables to determine if a feature is enabled or not. * Introduces consistent naming patterns for feature ENV variables. Document any side effects to this change: * This only introduces the new feature flag system. No existing feature flags have been migrated yet and FlipFlip is still present.
- Also includes Yard
7b00392 to
a5d6666
Compare
Pull Request Test Coverage Report for Build 18760201952Details
💛 - Coveralls |
Why are these changes being introduced:
more problems than it is solving. We need a simpler, more maintainable
feature flag system.
based on environment variables.
Relevant ticket(s):
How does this address that need:
to determine if a feature is enabled or not.
for checking if a feature is enabled.
Document any side effects to this change:
feature flags have been migrated yet and FlipFlip is still present.
yardto allow for documentation generationDeveloper
Accessibility
New ENV
Approval beyond code review
Additional context needed to review
E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.
Code Reviewer
Code
added technical debt.
Documentation
(not just this pull request message).
Testing