Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 2.06 KB

README.md

File metadata and controls

72 lines (49 loc) · 2.06 KB

Rack::Wreck Build Status

Selectively cause requests to your rack app to fail - the idea being that by having an artifically flakey API, you are forced to build resilience in to your clients (à la Chaos Monkey from Netflix).

Getting started

Install the Rack::Wreck gem; or add it to your Gemfile with bundler:

# In your Gemfile
gem 'rack-wreck'

Tell your app to use the Rack::Wreck middleware. For Rails apps:

# In config/application.rb
config.middleware.use Rack::Wreck

Or for Rackup files:

# In config.ru
require "rack/wreck"
use Rack::Wreck

See examples for example apps/configrations.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jkburges/rack-wreck. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Thanks to the rack-attack gem for providing a great basis for writing rack middleware!

Todo

  • rules matched top to bottom

  • what to fail?

    • block which takes rack env
  • when to fail?

  • how to fail?

    • the normal Rack response, e.g. ['500', {'Content-Type' => 'text/html'}, ["You've been wrecked!"]]

Example configuration

Rack::Wreck.rules do
  override "/login", method: :post, chance: 0.1, status: 500
  override /widget/, chance: 0.05, status: 403, body: ["Nice try!"]
end

It's also possible to delay responses as follows:

Rack::Wreck.configure do
  delay "/expensive", duration: 5.seconds
  # TODO: distributions from https://github.com/clbustos/distribution
end