Slide 1

Slide 1 text

Feature toggles

Slide 2

Slide 2 text

@lucasmazza https://afterhours.io

Slide 3

Slide 3 text

https://magnetis.workable.com

Slide 4

Slide 4 text

Feature Toggles 101

Slide 5

Slide 5 text

https://martinfowler.com/bliki/FeatureToggle.html

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

http://code.flickr.net/2009/12/02/flipping-out/ “Flickr is somewhat unique in that it uses a code repository with no branches; everything is checked into head, and head is pushed to production several times a day. ”

Slide 11

Slide 11 text

“Flags allow us to restrict features to certain environments, while still using the same code base on all servers.” http://code.flickr.net/2009/12/02/flipping-out/

Slide 12

Slide 12 text

“How do you use Continuous Integration to keep everyone working on the mainline without revealing a half- implemented feature on your releases? ” https://martinfowler.com/bliki/FeatureToggle.html

Slide 13

Slide 13 text

Trunk based development + Mudanças demoradas = FEATURE TOGGLEs

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

“Feature Toggles are a powerful technique, allowing teams to modify system behavior without changing code.” https://martinfowler.com/articles/feature-toggles.html

Slide 16

Slide 16 text

https://martinfowler.com/articles/feature-toggles.html

Slide 17

Slide 17 text

release toggles

Slide 18

Slide 18 text

↗ ↘ ✅ ➡ ➡

Slide 19

Slide 19 text

ops toggles

Slide 20

Slide 20 text

↗ ↘ ☁ ➡ ➡

Slide 21

Slide 21 text

http://confreaks.tv/videos/rubyconf2014-easy-rewrites-with-ruby-and-science

Slide 22

Slide 22 text

permission toggles

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

experiment toggles

Slide 25

Slide 25 text

https://martinfowler.com/articles/feature-toggles.html

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

NEW_SHINY_THING_ENABLED=1 bin/rails s

Slide 28

Slide 28 text

# config/toggles.yml development: shiny_new_thing: true production: shiny_new_thing: false

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

jnunemaker/flipper

Slide 31

Slide 31 text

gem 'flipper' gem 'flipper-redis' gem 'flipper-ui'

Slide 32

Slide 32 text

# config/initializers/flipper.rb Flipper.configure do |config| config.default do adapter = Flipper::Adapters::Redis.new(Redis.new) Flipper.new(adapter) end end

Slide 33

Slide 33 text

class DashboardsController < ApplicationController def show if Flipper.enabled?(:new_dashboard, current_user) render 'dashboards/new_dashboard' else render 'dashboards/current_dashboard' end end end

Slide 34

Slide 34 text

Adapters & Gates & Plugins

Slide 35

Slide 35 text

ADAPTERS Flipper::Adapters::Memory Flipper::Adapters::Http flipper-activerecord flipper-active_support_cache_store flipper_dalli flipper_mongo flipper_redis flipper_sequel flipper_consul

Slide 36

Slide 36 text

Gates Boolean Actor Group % of Actors % of Time

Slide 37

Slide 37 text

boolean gate Flipper.enabled?(:feature_name) # => false Flipper.enable(:feature_name) Flipper.enabled?(:feature_name) # => true

Slide 38

Slide 38 text

aCTOR gate class User def flipper_id "User:#{to_param}" end end Flipper.enabled?(:feature_just_for_you, current_user) Flipper.enable_actor(:feature_just_for_you, User.find(1))

Slide 39

Slide 39 text

GROUP gate Flipper.register(:staff_users) do |actor| actor.respond_to?(:staff?) && actor.staff? end Flipper.enabled?(:staff_panel, current_user) Flipper.enable_group(:staff_panel, :staff_users)

Slide 40

Slide 40 text

GROUP gate Flipper.register(:staff_users) do |actor| actor.respond_to?(:staff?) && actor.staff? end Flipper.register(:premium_clients) do |actor| actor.respond_to?(:subscription) && actor.subscription.plan_name == :premium end

Slide 41

Slide 41 text

% gates Flipper.enable_percentage_of_actors(:new_search, 33) Flipper.enabled?(:new_search, User.find(1)) # => false Flipper.enabled?(:new_search, User.find(2)) # => false Flipper.enabled?(:new_search, User.find(3)) # => true Flipper.enable_percentage_of_time(:v2_header, 50) Flipper.enabled?(:v2_header) # => false Flipper.enabled?(:v2_header) # => true

Slide 42

Slide 42 text

UI

Slide 43

Slide 43 text

UI # config/routes.rb Rails.application.routes.draw do mount Flipper::UI.app(Flipper) => ‘/flipper/api’ end

Slide 44

Slide 44 text

API # config/routes.rb Rails.application.routes.draw do mount Flipper::Api.app(Flipper) => '/flipper' end

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

“Release toggles are a useful technique and lots of teams use them. However they should be your last choice when you're dealing with putting features into production.” https://martinfowler.com/bliki/FeatureToggle.html

Slide 48

Slide 48 text

feature toggles são uma ferramenta de disponibilização de software

Slide 49

Slide 49 text

configurações da app não são toggles

Slide 50

Slide 50 text

configurações da app não são toggles toggle ou regra de negócio?

Slide 51

Slide 51 text

configurações da app não são toggles toggle ou regra de negócio? qual a diferença entre manter vs remover?

Slide 52

Slide 52 text

configurações da app não são toggles toggle ou regra de negócio? qual a diferença entre manter vs remover? será que não é só trauma de deploys ruins?

Slide 53

Slide 53 text

testes

Slide 54

Slide 54 text

testes servidores e clientes

Slide 55

Slide 55 text

testes servidores e clientes bancos de dados e serviços externos

Slide 56

Slide 56 text

feature toggles eventualmente são débitos técnicos

Slide 57

Slide 57 text

planejar e priorizar remoções

Slide 58

Slide 58 text

planejar e priorizar remoções testes de expiração

Slide 59

Slide 59 text

planejar e priorizar remoções testes de expiração limites de inventário

Slide 60

Slide 60 text

https://martinfowler.com/articles/feature-toggles.html

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

@lucasmazza https://speakerdeck.com/lucas Obrigado :)