disqus / gargoyle

Feature switches in Django
http://engineering.disqus.com
Apache License 2.0
748 stars 112 forks source link

Adding dynamic values for switches #25

Open dcramer opened 13 years ago

dcramer commented 13 years ago

Gargoyle should be able to handle values other than True/False for switches. This allows you to avoid duplication of "settings" when you want to say "this is either on, or off, and when its on the value should be FOO".

An example API may look like:

sqt = int(gargoyle.get_value('log_slow_query_threshold'))
if sqt:
    logging.info('slow query over threshold of %d!', sqt)

The default values for get_value would be True if enabled, False if not.

In the UI upon add/edit switch you'd be able to customize these values. Considerations are if they should only be strings. Otherwise we could allow JSON values but that means you'd be required to quote strings.

We'd also add the ability to set per-condition specific values. So if condition matches foo, the return value is 100 instead of 10.

anandology commented 13 years ago

Are you suggesting to make gargoyle.get_value('..') return a value instead of True/False?

dcramer commented 13 years ago

@anandology only if you configure a non-default return value. In this way Gargoyle could serve as a switches platform with varying responses depending on conditions. It would also make it more suitable for doing things like a/b testing (e.g. maybe under condition a, you want template.html, condition b, template2.html, and condition c template3.html).

anandology commented 13 years ago

Got it.

At openlibrary, we have pluggable conditions that can take parameters, but the return value is always boolean.