Skip to content

snluu/commander

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

commander

Build Status

Commander is a simple shard that lets you dispatch many concurrent calls at once, then collect the result afterwards.

Commander also allows the caller to choose the maximum concurrency for the given job.

API doc can be found at https://www.luu.io/projects/commander/api/

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  commander:
    github: snluu/commander
  1. Run shards install

Usage

See the spec for more details/examples.

require "commander"

cmd = Commander(Int32).new
result = nil

elapsed = Time.measure do
  1000.times do |x|
    cmd.dispatch do
      sleep 1.seconds
      x
    end
  end

  result = cmd.collect
end

result = result.not_nil!
result.size.should eq(1000)
1000.times do |x|
  result.should contain(x)
end

# 5 seconds is a very generous buffer.
# The point is it should not take 1000 seconds
elapsed.should be < 5.seconds

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published