You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by nickva <gi...@git.apache.org> on 2016/10/06 02:32:25 UTC

[GitHub] couchdb-config pull request #14: Features API and implementation.

GitHub user nickva opened a pull request:

    https://github.com/apache/couchdb-config/pull/14

    Features API and implementation.

    Implement ability to enable, disable and query feature flags.
    
    Features are identified as binary strings. Usage intent is for
    various components in the system to enable features, then the HTTP API will
    expose those to the user. For example, features could indicate the presence
    of an optional component, a plugin or a new mode of operation.
    
    The API has 3 functions:
    
     * `config:features/0` : Return a sorted list of feature flags
    
     * `config:feature_enable/1` : Enables a feature. Feature argument could be a
       list, a binary or an atom.
    
     * `config:feature_disable/1` : Same as `feature_enable/1` but disables the
       feature.
    
    `feature_enable/1` and `feature_disable/1` are idempotent.
    
    Implementation is a thin wrapper around setting and deleting keys from the
    '[features]' config section. This means, users can also set their own features
    there via the .ini config files. Features set via the API are not persistent,
    so applications will have to set them every time they initialize.
    
    Jira: COUCHDB-3180

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloudant/couchdb-config couchdb-3180

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-config/pull/14.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #14
    
----
commit d811a5472a91016633e217a2992df4c9ea88b876
Author: Nick Vatamaniuc <va...@apache.org>
Date:   2016-10-06T02:08:51Z

    Features API and implementation.
    
    Implement ability to enable, disable and query feature flags.
    
    Features are identified as binary strings. Usage intent is for
    various components in the system to enable features, then the HTTP API will
    expose those to the user. For example, features could indicate the presence
    of an optional component, a plugin or a new mode of operation.
    
    The API has 3 functions:
    
     * `config:features/0` : Return a sorted list of feature flags
    
     * `config:feature_enable/1` : Enables a feature. Feature argument could be a
       list, a binary or an atom.
    
     * `config:feature_disable/1` : Same as `feature_enable/1` but disables the
       feature.
    
    `feature_enable/1` and `feature_disable/1` are idempotent.
    
    Implementation is a thin wrapper around setting and deleting keys from the
    '[features]' config section. This means, users can also set their own features
    there via the .ini config files. Features set via the API are not persistent,
    so applications will have to set them every time they initialize.
    
    Jira: COUCHDB-3180

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config pull request #14: Features API and implementation.

Posted by nickva <gi...@git.apache.org>.
Github user nickva commented on a diff in the pull request:

    https://github.com/apache/couchdb-config/pull/14#discussion_r87080213
  
    --- Diff: src/config.erl ---
    @@ -183,6 +187,26 @@ delete(Section, Key, Persist, Reason) when is_list(Section), is_list(Key) ->
         gen_server:call(?MODULE, {delete, Section, Key, Persist, Reason}).
     
     
    +features() ->
    +    lists:usort([list_to_binary(Key) || {Key, "true"} <- ?MODULE:get(?FEATURES)]).
    +
    +
    +feature_enable(Feature) when is_atom(Feature) ->
    --- End diff --
    
    Yeah enable_feature/disable_feature sounds better. Can make it an atom as well.
    
    vs `add/remove`, `enable/disable` has more of an idempotent feel to it.  But ok with either way.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config issue #14: Features API and implementation.

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the issue:

    https://github.com/apache/couchdb-config/pull/14
  
    Don't get me wrong about your effort for pushing this feature forward. I worry about all future oblivious improvements for this feature which aren't fit into current implementation. So it'll have to be changed and since it's a thing that users may use in own fashion, such changes may not be harmless.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config issue #14: Features API and implementation.

Posted by nickva <gi...@git.apache.org>.
Github user nickva commented on the issue:

    https://github.com/apache/couchdb-config/pull/14
  
    @kxepal 
    
    > Well, if we're agree that features should be discoverable, may be not introduce intermediate short live solutions that will break backward compatibility at some point? 
    
    They are discoverable. config:features() returns all feature flags.
    
    > I worry about all future oblivious improvements for this feature which aren't fit into current implementation. 
    
    Then we'll change the implementation. Where you thinking of a whole new application or other such thing?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config issue #14: Features API and implementation.

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the issue:

    https://github.com/apache/couchdb-config/pull/14
  
    Well, if we're agree that features should be discoverable, may be not introduce intermediate short live solutions that will break backward compatibility at some point? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config pull request #14: Features API and implementation.

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-config/pull/14#discussion_r87077093
  
    --- Diff: src/config.erl ---
    @@ -183,6 +187,26 @@ delete(Section, Key, Persist, Reason) when is_list(Section), is_list(Key) ->
         gen_server:call(?MODULE, {delete, Section, Key, Persist, Reason}).
     
     
    +features() ->
    +    lists:usort([list_to_binary(Key) || {Key, "true"} <- ?MODULE:get(?FEATURES)]).
    +
    +
    +feature_enable(Feature) when is_atom(Feature) ->
    --- End diff --
    
    or maybe `add_feature` / `remove_feature`. I think you're only supporting `remove_feature` for testing?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config issue #14: Features API and implementation.

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the issue:

    https://github.com/apache/couchdb-config/pull/14
  
    @nickva 
    After good sleep time I think there is no conflicts here. Yes, features need to be discovered, but yes, user need to have an option to turn on/off them easily without doing fancy Erlang tricks. 
    
    So config true/false switches is how user may control features availability. I'm hard to image a case when I would shutdown some feature, but it looks useful.
    
    So I take my words back, sorry for that. 
    
    > Where you thinking of a whole new application or other such thing?
    
    I think new app is a good idea to group there all the features-related logic which will grow in time. For instance, `config:features` is a bit misplaced here, but for now there is no better place for it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config issue #14: Features API and implementation.

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the issue:

    https://github.com/apache/couchdb-config/pull/14
  
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-config pull request #14: Features API and implementation.

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-config/pull/14#discussion_r87076913
  
    --- Diff: src/config.erl ---
    @@ -183,6 +187,26 @@ delete(Section, Key, Persist, Reason) when is_list(Section), is_list(Key) ->
         gen_server:call(?MODULE, {delete, Section, Key, Persist, Reason}).
     
     
    +features() ->
    +    lists:usort([list_to_binary(Key) || {Key, "true"} <- ?MODULE:get(?FEATURES)]).
    +
    +
    +feature_enable(Feature) when is_atom(Feature) ->
    --- End diff --
    
    `enable_feature` and `disable_feature` reads better, what do you think? Also, can we insist on atom rather than handle atom and binary and list?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---