Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Release new features using feature sliders

Release new features using feature sliders

A presentation of the arturo gem

Dimiter Petrov

November 20, 2013
Tweet

More Decks by Dimiter Petrov

Other Decks in Programming

Transcript

  1. Release new features
    using feature sliders
    Dimiter Petrov
    @crackofdusk
    20 November 2013

    View Slide

  2. Introduction

    View Slide

  3. A feature can be too large for a single
    development cycle

    View Slide

  4. A feature may need testing by a small
    group before being deployed to all users

    View Slide

  5. You need fine-grained control over
    feature deployment

    View Slide

  6. Feature sliders

    View Slide

  7. Feature sliders
    Turn on and off features for some of the
    users

    View Slide

  8. Feature sliders with the
    arturo gem

    View Slide

  9. Integrating arturo in your
    application
    1. Create migration for features table
    2. Add configuration initializer
    3. Mount arturo engine in the router
    4. Run migration
    5. Use arturo helpers to wrap features

    View Slide

  10. Features table
    Needs a column for feature names and a
    column for deployment percentage

    View Slide

  11. Deployment percentage?
    Feature X can be deployed to m percent of
    the users

    View Slide

  12. Deployment percentage?
    Feature X can be deployed to m percent of
    the users
    Deterministic: a feature is consistently
    enabled from now on for that m percent of
    users unless you decrease the deployment
    percentage.

    View Slide

  13. Feature conditionals

    View Slide

  14. Controller filters
    class ReservationsController < ApplicationController
    require_feature :reserve_table
    end

    View Slide

  15. Conditional evaluation
    def widgets_for_sidebar
    widgets = []
    widgets <<
    twitter_widget if feature_enabled?(:tweeting)
    # ...
    widgets
    end

    View Slide

  16. Conditional evaluation
    <% if_feature_enabled(:reserve_table) %>
    <%=
    link_to
    ’Reserve a table’,
    new_restaurant_reservation_path(restaurant)
    %>
    <% end %>

    View Slide

  17. Feature conditionals
    oustide controllers
    Arturo.feature_enabled_for?(:reserve_table, recipient)
    Arturo.reserve_table_enabled_for?(recepient)

    View Slide

  18. Fine-grained control

    View Slide

  19. Whitelists & blacklists
    # config/initializers/arturo_initializer.rb
    Arturo::Feature.whitelist(:awesome) do |user|
    user.account.premium?
    end
    Arturo::Feature.blacklist(:goodies) do |user|
    user.account.free?
    end

    View Slide

  20. Feature recepients
    The current “thing” that is in the category
    thatisthebasisfordeployingnewfeatures.
    E.g: a user, an account, a project, a venue,…

    View Slide

  21. Feature recepients
    # config/initializers/arturo_initializer.rb
    Arturo.feature_recipient do
    current_project
    end

    View Slide

  22. Feature administration

    View Slide

  23. Feature administration
    Navigate to /features and manage
    features from the mounted rails engine

    View Slide

  24. Administration permissions
    # Default permissions
    current_user.present? && current_user.admin?

    View Slide

  25. Administration permissions
    # Default permissions
    current_user.present? && current_user.admin?
    # config/initializers/arturo_initializer.rb
    Arturo.permit_management do
    signed_in? && current_user.can?(:manage_features)
    end

    View Slide

  26. Live demo
    https://github.com/happydawn/arturo-test

    View Slide

  27. Thank you!

    View Slide