Project

muxer

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Muxer allows timeouts to be set for each request made in addition to a global timeout for a set of requests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
~> 0.10
~> 10.4
~> 3.2
~> 2.9
~> 1.20

Runtime

 Project Readme

Muxer

Quality Coverage Build Dependencies Docs Issues Downloads Tags Releases License Version

Muxer is a gem to allow web requests to run in parallel with seperate timeouts per request, in addition to an optional global timeout for all of the requests.

For example:

  • Request 1 (Internal API) - 5 second timeout
  • Request 2 (External) - 1 second timeout
  • Request 3 (External) - 1 second timeout
  • Request 4 (External) - 1 second timeout

Requests 2-4 will be allowed to continue waiting after their timeouts if we are still waiting on Request 1; however, if Request 1 comes back in half a second, we will finish ALL requests at the 1 second timeout. Any requests not finished within the timeouts will be added to the :failed array in the response.

Installation

Add this line to your application's Gemfile:

gem 'muxer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install muxer

Usage

response = Muxer.execute do |muxer|
  muxer.add_url "http://www.rubydoc.info"
  muxer.add_url "https://www.google.com"
end

response[:failed] == []
response[:succeeded] == [
  Muxer::Request(url: "http://www.rubydoc.info"),
  Muxer::Request(url: "https://www.google.com")
]

Contributing

  1. Fork it ( https://github.com/[my-github-username]/muxer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request