Waffle
Toby Champion
github.com/tobych
Feature switches for Django
Feature branches are nasty
• Must deploy a branch to try things out
• Unlikely to run full tests on a branch
• Many branches: painful and confusing
• Branching inhibits refactoring
Feature Switches
Allow you to include all new features on your
master branch, hiding them from users so you
can deploy all your code to production.
Now you can hide features!
• Features are developed in master
alongside others
• You have separate deploy and release steps
• Your work need not impact users until ready
• Leave branching just for spikes
• Tests on master run on all features
• Code is more often ready to deploy
Let’s use feature switches!
Let’s use feature switches!
Use your switches everywhere
• Templates
• JavaScript
• Views
• Models
• Jinja2 templates (via Jingo)
• Mustache/Handlebars templates
• Management commands
• Celery tasks
{% load waffle_tags %}
{% switch switch_name %}
Switch is active!
{% else %}
Switch is inactive!
{% endswitch %}
Django template
Views
Wrap an entire view
JavaScript
Examples
Switches
show_replace_button
Show icon for incomplete feature
show_custom_fields
Show custom fields on the edit dialog (delete this switch!)
no_fancy_tag_defaults
Disable broken JavaScript code until we fix it
debug_live
Write extra live update debugging info to JavaScript console
use_reftag_kalman_filtering
Use kalman filtering for reference tag barometer smoothing
Flags
Flags know about users and groups
Examples
Flags
show_manage_rules
Show navigation item for new rule manager feature
use_selections
Use new fancy check-box selection instead of drag’n’drop
no_xmpp
Don’t try to contact XMPP (BOSH) server at page load
no_maps
Don’t try to load map tiles at page load
Query string
http://example.com/?dwft_my_flag=0 – Off
http://example.com/?dwft_my_flag=1 – On
Persisted for the session using cookies.
Also use Waffle for
• A/B testing (Waffle chooses randomly)
• Canary releasing (roll out to % of users)
Be careful!
• Even inactive code can break your product
• Unit tests must cover both cases
• Integration tests should cover combinations
• Remove unused switches!
• Harder to follow code wrapped in switches
Pain
Persistence
• memcached
• Redis
Waffle
• http://coffeeonthekeyboard.com/introducing-waffle-for-django-541/
• https://github.com/jsocol/django-waffle
• http://waffle.readthedocs.org/
Feature Switches/Flags/Bits/Toggles
• http://martinfowler.com/bliki/FeatureToggle.html
• http://www.pgrs.net/2011/08/29/why-i-dont-like-feature-branches/
• http://blog.disqus.com/post/789540337/partial-deployment-with-feature-switches
• http://arialdomartini.wordpress.com/2011/11/02/help-me-because-i-think-martin-fowler-has-a-merge-paranoia/
• http://www.youtube.com/watch?v=xzstASOvqNc
• http://codeascraft.com/2011/02/04/how-does-etsy-manage-development-and-operations/
• http://www.infoq.com/presentations/Feature-Bits
Toby Champion
@tobych
linkedin.com/in/tobychampion
github.com/tobych/
toby@tobychampion.com
Seattle Python Day 2013
• Seattle Python Interest Group (SeaPIG)
• Late September?
• One day (Saturday)
• Free or at least very cheap
• Sprints on the Sunday?
Waffle: A feature switch/flag/toggle application for Django

Waffle: A feature switch/flag/toggle application for Django

Editor's Notes

  • #2 Waffle, a Django application that provides “feature switches”, which let you deploy the code for a new feature without showing it to the user.
  • #3 Working with RECON Dynamics, a start-up headquartered in Kirkland, which makes these asset trackers that have sensors and radio transmitters in so you can monitor stuff remotely and locate them.
  • #4 Looking more closely at thatscreengrabSee that this generator has been running for 1 hour, and that it’s in a parking lot by the beachfront in Carillon Point
  • #5 A lot of developers use feature branchesWho uses feature branchesEspecially as Git makes it so easy to create, delete and merge branchesEven with CI, running full suite of unit and integration tests on a branch is painful, so less likely to do itIf you’re working on a lot of features at once, things can get pretty overwhelming
  • #7 Being able to hide changes from users lets you do things differently
  • #8 So some feature switch solutions for Django.But wait, this is Rover.com, not Felix.com…
  • #10 Waffle is the most popular if you look at downloads. the other main candidate is Gargoyle (David Cramer), which we started out with but moved away from as it relies on Disqus' Nexus admin replacement thing, which is a little heavy and a little buggy for us.
  • #11 Waffle is the most popular if you look at downloads. the other main candidate is Gargoyle (David Cramer), which we started out with but moved away from as it relies on Disqus' Nexus admin replacement thing, which is a little heavy and a little buggy for us.