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 Feature Toggles #18699
base: master
Are you sure you want to change the base?
Add Feature Toggles #18699
Conversation
4e1460c
to
4334dcf
Compare
4334dcf
to
8d079a9
Compare
@bot kick off tests |
19b43a4
to
420f154
Compare
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.
Shall we add more documentation/comments inside code, for each new component, annotation use case, and each test case as a living doc.
...e-toggle/src/main/java/com/facebook/presto/features/config/FileBasedFeatureToggleModule.java
Outdated
Show resolved
Hide resolved
...e-toggle/src/main/java/com/facebook/presto/features/config/FileBasedFeatureToggleModule.java
Outdated
Show resolved
Hide resolved
presto-feature-toggle/src/test/java/com/facebook/presto/features/binder/FeatureToggleTests.java
Show resolved
Hide resolved
presto-feature-toggle/src/test/java/com/facebook/presto/features/classes/Feature01.java
Outdated
Show resolved
Hide resolved
...eature-toggle/src/test/java/com/facebook/presto/features/config/FeatureToggleConfigTest.java
Show resolved
Hide resolved
presto-feature-toggle/src/test/java/com/facebook/presto/features/binder/FeatureToggleTests.java
Show resolved
Hide resolved
presto-feature-toggle/src/test/java/com/facebook/presto/features/binder/FeatureToggleTests.java
Outdated
Show resolved
Hide resolved
235b92d
to
c388407
Compare
9778a00
to
b9c6a41
Compare
313bdf0
to
eaf007a
Compare
eaf007a
to
f8e069a
Compare
f8e069a
to
227d83f
Compare
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.
Can you remove the custom parsing code and reuse the code in airlift/configuration
to parse individual FeatureConfiguration
s?
...feature-toggle/src/main/java/com/facebook/presto/features/annotations/FeatureToggleImpl.java
Outdated
Show resolved
Hide resolved
presto-feature-toggle/src/main/java/com/facebook/presto/features/annotations/FeatureToggle.java
Show resolved
Hide resolved
...to-feature-toggle/src/main/java/com/facebook/presto/features/annotations/FeatureToggles.java
Outdated
Show resolved
Hide resolved
presto-feature-toggle/src/main/java/com/facebook/presto/features/http/FeatureStrategyInfo.java
Show resolved
Hide resolved
presto-feature-toggle/src/main/java/com/facebook/presto/features/http/FeatureDetails.java
Show resolved
Hide resolved
063f700
to
b15bd98
Compare
b15bd98
to
7a9e402
Compare
4ec2497
to
a2588ed
Compare
a2588ed
to
f3d2b44
Compare
27bcf68
to
21fc7fe
Compare
...o-feature-toggle/src/main/java/com/facebook/presto/features/config/FeatureConfiguration.java
Outdated
Show resolved
Hide resolved
d9da818
to
754839f
Compare
...to-feature-toggle/src/main/java/com/facebook/presto/features/binder/PrestoFeatureToggle.java
Outdated
Show resolved
Hide resolved
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.
One major thing that seems to be missing is: I thought there would be a plugin mechanism that would allow one to change how the toggles are persisted and loaded? Without that, how does one even use the FileBasedFeatureToggleModule
, since it seems to be unused in this PR?
...to-feature-toggle/src/main/java/com/facebook/presto/features/binder/FeatureToggleBinder.java
Show resolved
Hide resolved
import static com.google.common.base.Suppliers.memoizeWithExpiration; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
||
public class FileBasedFeatureToggleModule |
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.
Is this unused?
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.
FileBasedFeatureToggleModule
is a FeatureToggle module for file-based configuration.
For other configuration sources, we can create and initialize other modules. for example: DatabaseBasedFeatureToggleModule
.
I'll try to refactor this and extract the configuration sources parser in a separate class, and we will have a FeatureToggleModule
and configuration parsers based on configuration sources
presto-feature-toggle/src/main/java/com/facebook/presto/features/http/FeatureDetails.java
Outdated
Show resolved
Hide resolved
d1fb89d
to
3b7611d
Compare
3b7611d
to
6d1519a
Compare
HI @tdcmeehan, |
Thank you for refactoring this into a plugin. Can you please make sure that all the file-based loading code is in one module, and all the core code to wire in feature toggles is in a separate module? One may want to swap out the file reading code with something e.g. db backed, without depending on the file loading code. What happens if we add a feature toggle in the code, but the operator hasn't added a configuration source plugin? |
6d1519a
to
add50b4
Compare
HI @tdcmeehan, |
@branimir-vujicic This requires a release note since this is introducing a new feature. Can you please add that in. |
@branimir-vujicic Are the Velox changes needed as a part of this PR. ? Seems unrelated. Can you please remove them. |
add50b4
to
1baaef4
Compare
@ajaygeorge Velox updates are included by mistake. |
a5d9d0a
to
951249c
Compare
Feature Toggles should allow teams to modify system behavior without changing code. Feature Toggles are configured using google guice. Basic definition of toggles are crated using FeatureToggleBinder. FeatureToggleBinder creates FeatureToggle and additional configuration can be done using feature configuration. In current stage Feature Toggles supports: - if / else based feature toggles - Dependency Injection based Hot reloading implementation without restart require code refactoring to add an interface when injecting the new implementation/class - using various toggle strategies along with simple on / off toggles configuration: to allow feature toggle configuration four lines are needed in config.properties file ``` features.config-source-type=file features.config-source=/etc/feature-config.properties features.config-type=properties features.refresh-period=30s ``` `configuration-source-type` is source type for Feature Toggles configuration `features.config-source` is a source (file) of the configuration `features.config-type` format in which configuration is stored (json or properties) `features.refresh-period` configuration refresh period Defining Feature Toggles Feature toggle definition is done in google guice module using `FeatureToggleBinder` simple feature toggle definition ``` featureToggleBinder(binder) .featureId("featureXX") .bind() ``` This example creates bindings for @Inject ``` @Inject public Runner(@FeatureToggle("featureXX") Supplier<Boolean> isFeatureXXEnabled) { this.isFeatureXXEnabled = isFeatureXXEnabled; } ``` `isFeatureXXEnabled` can be used to test if feature is enabled or disabled: ``` boolean testFeatureXXEnabled() { return isFeatureXXEnabled.get(); } ``` hot reloadable feature toggle definition ``` featureToggleBinder(binder, Feature01.class) .featureId("feature01") .baseClass(Feature01.class) .defaultClass(Feature01Impl01.class) .allOf(Feature01Impl01.class, Feature01Impl02.class) .bind() ``` adding Feature Toggle switching strategy ``` featureToggleBinder(binder) .featureId("feature04") .toggleStrategy("AllowAll") .toggleStrategyConfig(ImmutableMap.of("key", "value", "key2", "value2")) ``` feature-config.properties file example ``` # feature query-logger feature.query-logger.enabled=true feature.query-logger.strategy=OsToggle feature.query-logger.strategy.os_name=.*Linux.* #feature.query-rate-limiter feature.query-rate-limiter.currentInstance=com.facebook.presto.server.protocol.QueryBlockingRateLimiter # feature.query-cancel feature.query-cancel.strategy=AllowList feature.query-cancel.strategy.allow-list-source=.*IDEA.* feature.query-cancel.strategy.allow-list-user=.*prestodb ``` in this example for first feature `query-logger` changing value of feature.query-logger.enabled to `false` will 'disable' this feature. Changes will be effective within refresh period.
951249c
to
b1bb436
Compare
Feature Toggles should allow teams to modify system behavior without changing code. Feature Toggles are configured using google guice. Basic definition of toggles are crated using FeatureToggleBinder. FeatureToggleBinder creates FeatureToggle and additional configuration can be done using feature configuration.
In current stage Feature Toggles supports:
configuration:
to allow feature toggle configuration four lines are needed in config.properties file
configuration-source-type
is source type for Feature Toggles configurationfeatures.config-source
is a source (file) of the configurationfeatures.config-type
format in which configuration is stored (json or properties)features.refresh-period
configuration refresh periodDefining Feature Toggles
Feature toggle definition is done in google guice module using
FeatureToggleBinder
simple feature toggle definition
This example creates bindings for @Inject
isFeatureXXEnabled
can be used to test if feature is enabled or disabled:hot reloadable feature toggle definition
adding Feature Toggle switching strategy
feature-config.properties file example
in this example for first feature
query-logger
changing value of feature.query-logger.enabled to
false
will 'disable' this feature. Changes will be effective within refresh period.Test plan - Unit Tests