Tog (short for toggle) is a framework for clients and servers to converse about feature flags over Redis.
A flag and its current value.
Type: Hash Map
Key: tog3:flags:{namespace}
Field: {name}
Value:
{
"description": "Sets the call-to-action button color to blue",
"timestamp": 1590748359,
"rollout": [
{
"percentage": 30,
"value": true
},
{
"traits": ["early_adopter"],
"value": true
},
{
"value": false
}
]
}
If multiple strategies are defined for one rollout option, they will be applied with the AND operator. If no rollout rule is matched, then the fallback value for the flag is false
.
percentage
: will randomly assign the value to X percent of the sessions. Example:{ "percentage": 30 }
traits
: will assign the value when the session's traits match all of the rollout's traits. Example:{ "traits": ["early_adopter"] }
Random assignment of percentages MUST follow this criteria:
- Key = take the input session ID and concatenate it with the flag's timestamp
- Hash = use the previous string as key for computing a Murmur3 (32b) hash
- Mod = take the modulo of the division of the hash by 100
- Consider the rollout expression if Mod < percentage
A client implementation MAY adopt a memory cache for a namespace's flag list, in which case it must subscribe to tog3:namespace-changed
to clear the cache when a change happens.
HGETALL tog3:flags:{namespace}
HGET tog3:flags:{namespace} {name}
HSET tog3:flags:{namespace} {name} {flag-json}
PUBLISH tog3:namespace-changed {namespace}
HDEL tog3:flags:{namespace} {name}
PUBLISH tog3:namespace-changed {namespace}
- List flags
- For each flag, apply its rollout rules to figure out its state
- Clients:
- Node.js:
tog-node
- Node.js:
- Management server: server application that provides management of flags and experiments. Best used with Tog CLI.
- Session server: server application that provides an endpoint for fetching sessions
- CLI: command-line tool that interacts with the management server to update flags and experiments