Comment 3 for bug 669942

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 669942] Re: Needs docs for feature flag priority

On Fri, Nov 5, 2010 at 4:49 AM, Deryck Hodge <email address hidden> wrote:
> Robert, I don't mind updating the docstrings or wiki.  I don't get it,
> though.  I've heard "higher priority wins" before and it's not enough to
> help me understand it.  Currently, people are just incrementing the
> priority number with each new flag.  So it's better to say "newest flag
> wins," but why do I care?  Why are the flags fighting?  What flexibility
> does this add?  How should we design our flags with this priority in
> mind?

Great questions - and I wouldn't have thought to answer them all. So here goes.
We have scopes, rules and flags.
Flags are set from a rule.
The rule that determines the value of a flag is:
"The highest priority rule for that flag whose scope matches"

As an example consider two rules for timeouts:
hard_timeout team:admins 1 18000
hard_timeout default 0 15000

Asking for the flag 'hard_timeout' will cause the feature controller
to loop on these two rules - first the team:admins one, then the
default one. Any request for which the logged in user is an admin will
match the higher priority rule, all other requests will fall down to
the next rule.

Hope that helps.
-Rob