Skip to content

Instantly share code, notes, and snippets.

@jlebrech
Created July 22, 2013 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlebrech/6055020 to your computer and use it in GitHub Desktop.
Save jlebrech/6055020 to your computer and use it in GitHub Desktop.
class Url < ActiveRecord::Base
def find_link(url)
link = link_finder(url)
EM::Run {
link.callback {
p "done"
}
}
end
end
class MyWorker
include Sidekiq::Worker
def perfom(a_link)
urls = Domain.urls.all
urls.each { |url|
url.find_link(a_link)
}
# slow down cowboy
do_something_with(urls.first)
end
end
class MyWorker
include Sidekiq::Worker
def perfom(a_link)
urls = Domain.urls.all
EM.run {
EM::iterator.new(urls,10).map(proc { |url|
url.find_link(a_link)
}, proc {
do_something_with(urls.first)
})
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment