Raisin Frencn 'oast Belgian Waffle Pecan Waffle Bluebemy ...
Waffle: A feature switch/flag/toggle application for Django
-
Upload
tobych -
Category
Technology
-
view
1.870 -
download
0
description
Transcript of Waffle: A feature switch/flag/toggle application for Django
![Page 1: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/1.jpg)
Waffle
Toby Championgithub.com/tobych
Feature switches for Django
![Page 2: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/2.jpg)
![Page 3: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/3.jpg)
![Page 4: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/4.jpg)
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
![Page 5: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/5.jpg)
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.
![Page 6: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/6.jpg)
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
![Page 7: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/7.jpg)
Let’s use feature switches!
![Page 8: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/8.jpg)
Let’s use feature switches!
![Page 9: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/9.jpg)
![Page 10: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/10.jpg)
![Page 11: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/11.jpg)
![Page 12: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/12.jpg)
Use your switches everywhere
• Templates• JavaScript• Views• Models• Jinja2 templates (via Jingo)• Mustache/Handlebars templates• Management commands• Celery tasks
![Page 13: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/13.jpg)
{% load waffle_tags %}
{% switch switch_name %} Switch is active!{% else %} Switch is inactive!{% endswitch %}
Django template
![Page 14: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/14.jpg)
Views
![Page 15: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/15.jpg)
Wrap an entire view
![Page 16: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/16.jpg)
JavaScript
![Page 17: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/17.jpg)
Examples
![Page 18: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/18.jpg)
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
![Page 19: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/19.jpg)
Flags
![Page 20: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/20.jpg)
Flags know about users and groups
![Page 21: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/21.jpg)
Examples
![Page 22: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/22.jpg)
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
![Page 23: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/23.jpg)
Query string
http://example.com/?dwft_my_flag=0 – Offhttp://example.com/?dwft_my_flag=1 – On
Persisted for the session using cookies.
![Page 24: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/24.jpg)
Also use Waffle for
• A/B testing (Waffle chooses randomly)• Canary releasing (roll out to % of users)
![Page 25: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/25.jpg)
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
![Page 26: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/26.jpg)
Pain
![Page 27: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/27.jpg)
![Page 28: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/28.jpg)
![Page 29: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/29.jpg)
![Page 30: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/30.jpg)
![Page 31: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/31.jpg)
Persistence
• memcached• Redis
![Page 32: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/32.jpg)
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
![Page 34: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/34.jpg)
![Page 35: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/35.jpg)
Seattle Python Day 2013
• Seattle Python Interest Group (SeaPIG)• Late September?• One day (Saturday)• Free or at least very cheap• Sprints on the Sunday?
![Page 36: Waffle: A feature switch/flag/toggle application for Django](https://reader033.fdocuments.us/reader033/viewer/2022061115/5463e015af795969338b468d/html5/thumbnails/36.jpg)