Project

shotgunner

0.0
The project is in a healthy, maintained state
Shotgunner - helps to fetch external api in a parallel way! Fast and furious!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Project Readme

Shotgunner

Gem GitHub last commit Gem

  1. Define options for parallel call
  2. Yield api caller into the run method.
  3. Enjoy shotgun's unstoppable performance of retrieving data :)
  4. Use assembled result's array.

Install

gem install shotgunner

Examples

class Service
  include Shotgunner::Parallel

  class << self
    def some_cool_logic
      urls_to_be_fetched = [URI('http://example.com/index.html?count=10'),
                            URI('http://example.com/index.html?count=20')]
      data = run tasks: urls_to_be_fetched, threads: 6 do |uri|
        Net::HTTP.get(uri)
      end
      
      ## do everything you need with received data array
      data.map{|j| JSON.parse(j)}

    end
  end
end