iilyak opened a new pull request #1682: Feature flags
URL: https://github.com/apache/couchdb/pull/1682
 
 
   ## Overview
   
   Once in a while we merge a highly experimental features. It is beneficial to 
be able to have the codepath for these features effectivelly disabled by 
default until the implementation is stabilized. 
   This PR introduces an ability to add feature flag checks for experimental 
features.   
   This feature is for developers only and wouldn't need documentation.
   
   ### The feature configuration
   
   ```
   [feature_flags]
   
   my_feature||* = false
   my_feature||mytestdatabaseprefix* = true
   ```
   
   Notes:
   - The `*` is only allowed at the end of the path
   - In order to distinguish between shards and clustered db the following 
convention is used.
     - it is a shard if pattern starts with `/`
   - It is also possible to enable multiple flags for the path using 
alternative syntax
     - `mytestdatabaseprefix* = [my_featureA, my_featureB]`
   
   ### Usage of the feature in the code
   
   ```
   case couch_flags:is_enabled(my_feature, Subject) of
       true -> ...;
       false -> ...
   end
   ```
   
   Where Subject is one of `#db{}` | `#httpd{)` | `#shard{}` | 
`#ordered_shard{}` | `ShardName :: binary()` | `ShardName :: list()` | `DbName 
:: binary()` | `DbName :: list()`
   
   ### Performance
   
   There is a naive performance test in the test suite it does 1 million of 
calls to `is_enabled/2`. One million of calls takes "1.884 s" on the laptop.
   
   ### Security
   
   It is not safe to allow configuration of the feature flags over http since 
there might be a possibility of injecting arbitrary code via name of the 
configuration key within `feature_flags` section. Therefore the http access is 
disabled. 
   
   ## Testing recommendations
   
   ```
   make eunit apps=couch suites=couch_flags_tests,couch_flags_config
   ```
   
   ## Related Issues or Pull Requests
   
   N/A
   
   ## Checklist
   
   - [x] Code is written and works correctly;
   - [x] Changes are covered by tests;
   - [ ] Documentation reflects the changes;
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to