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

Click here to load reader

  • date post

  • Category


  • view

  • download


Embed Size (px)



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

  • 1. WaffleToby Championgithub.com/tobychFeature switches for Django
  • 2. 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
  • 3. Feature SwitchesAllow you to include all new features on yourmaster branch, hiding them from users so youcan deploy all your code to production.
  • 4. 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
  • 5. Lets use feature switches!
  • 6. Lets use feature switches!
  • 7. Use your switches everywhere Templates JavaScript Views Models Jinja2 templates (via Jingo) Mustache/Handlebars templates Management commands Celery tasks
  • 8. {% load waffle_tags %}{% switch switch_name %}Switch is active!{% else %}Switch is inactive!{% endswitch %}Django template
  • 10. Wrap an entire view
  • 11. JavaScript
  • 12. Examples
  • 13. Switchesshow_replace_buttonShow icon for incomplete featureshow_custom_fieldsShow custom fields on the edit dialog (delete this switch!)no_fancy_tag_defaultsDisable broken JavaScript code until we fix itdebug_liveWrite extra live update debugging info to JavaScript consoleuse_reftag_kalman_filteringUse kalman filtering for reference tag barometer smoothing
  • 14. Flags
  • 15. Flags know about users and groups
  • 16. Examples
  • 17. Flagsshow_manage_rulesShow navigation item for new rule manager featureuse_selectionsUse new fancy check-box selection instead of dragndropno_xmppDont try to contact XMPP (BOSH) server at page loadno_mapsDont try to load map tiles at page load
  • 18. Query stringhttp://example.com/?dwft_my_flag=0 Offhttp://example.com/?dwft_my_flag=1 OnPersisted for the session using cookies.
  • 19. Also use Waffle for A/B testing (Waffle chooses randomly) Canary releasing (roll out to % of users)
  • 20. 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
  • 21. Pain
  • 22. Persistence memcached Redis
  • 23. 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
  • 24. Toby [email protected]/in/tobychampiongithub.com/tobych/[email protected]
  • 25. Seattle Python Day 2013 Seattle Python Interest Group (SeaPIG) Late September? One day (Saturday) Free or at least very cheap Sprints on the Sunday?