Code Monkey home page Code Monkey logo

trial's Introduction

Trial!

A Ruby library for trialing new systems that may still fail.

This is heavily based on the fantastic gem by the awesome people at Github called scientist: https://github.com/github/scientist/blob/master/README.md

Why use trial instead of scientist?

Trial is a tool we built as a natural successor to scientist.

It is not intended as a replacement for scientist, but rather a next step between running scientist experiments and firmly committing your new code to the production critical path.

In other words, we recommend you start by using scientist to refactor. But when you're convinced your new system or code is ready for primetime, trial can help you start using your new system with a safe fallback to the old system.

Trial lets you specify two codepaths: the new system, and the fallback system. It will attempt to run the new system, and if any unexpected exceptions occur, it will fall back to the old system.

The primary advantage it offers over scientist is that it doesn't by default incur the latency hit of running both the old & new systems. It only runs both if the new system fails.

How do I use it?

Let's say you have two systems that compute metrics. You are close to cutting over all your production traffic to use the new one, but you still want to make sure your customers aren't impacted if the new system has any unexpected problems or glitches. Trial lets you try the new system but fall back to the old system if any exceptions happen.

require 'fabric/trial'

class MyWidget
  include Fabric::Trial

  def compute_metrics
    attempt('new_auth_system') do |attempt|
      attempt.try { new_system.compute_metrics }
      attempt.fallback { old_system.compute_metrics }
    end
  end
end

It will only run the fallback if the new system has a failure.

Run tests

bundle install
bundle exec rake

trial's People

Contributors

jladieu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.