Raisin Frencn 'oast Belgian Waffle Pecan Waffle Bluebemy ...
Waffle: A feature switch/flag/toggle application for Django
-
Upload
tobych -
Category
Technology
-
view
1.881 -
download
0
description
Transcript of Waffle: A feature switch/flag/toggle application for Django
Waffle
Toby Championgithub.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 masteralongside 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
Switchesshow_replace_buttonShow icon for incomplete feature
show_custom_fieldsShow custom fields on the edit dialog (delete this switch!)
no_fancy_tag_defaultsDisable broken JavaScript code until we fix it
debug_liveWrite extra live update debugging info to JavaScript console
use_reftag_kalman_filteringUse kalman filtering for reference tag barometer smoothing
Flags
Flags know about users and groups
Examples
Flagsshow_manage_rulesShow navigation item for new rule manager feature
use_selectionsUse new fancy check-box selection instead of drag’n’drop
no_xmppDon’t try to contact XMPP (BOSH) server at page load
no_mapsDon’t try to load map tiles at page load
Query string
http://example.com/?dwft_my_flag=0 – Offhttp://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
Seattle Python Day 2013
• Seattle Python Interest Group (SeaPIG)• Late September?• One day (Saturday)• Free or at least very cheap• Sprints on the Sunday?