Skip to content
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

Add Strict adapter to ensure feature exists on get #760

Merged
merged 6 commits into from
Sep 21, 2023
Merged

Add Strict adapter to ensure feature exists on get #760

merged 6 commits into from
Sep 21, 2023

Conversation

bkeepers
Copy link
Collaborator

First pass at adding a strict adapter to ensure only features that exist can be called.

Flipper.configure do |config|
  config.adapter { Flipper::Adapters::Strict.new(Flipper::Adapters::ActiveRecord.new) }
end

Flipper.enabled?(:featuere_name) # raises Flipper::Adapters::Strict::NotFound

Flipper.add(:feature_name)

Flipper.enabled?(:feature_name) # => false

In a follow up PR I'm hoping to use this by default in Rails apps in development/test.

Copy link
Collaborator

@jnunemaker jnunemaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left a couple questions. I'd think get_multi should be in so there is a raise/warning for preloading the wrong feature name.

Copy link
Collaborator

@garrettdimon garrettdimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you envisioning that this would be used like in the example or would it also have some level of configuration? i.e. Is the configuration happening purely from how the initializer is called?

lib/flipper/adapters/strict.rb Outdated Show resolved Hide resolved
@bkeepers
Copy link
Collaborator Author

Are you envisioning that this would be used like in the example or would it also have some level of configuration? i.e. Is the configuration happening purely from how the initializer is called?

Still in progress, but this is what I am imagining: #763

@bkeepers bkeepers merged commit d06da06 into main Sep 21, 2023
50 checks passed
@bkeepers bkeepers deleted the strict branch September 21, 2023 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants