Created
July 22, 2013 15:59
-
-
Save jlebrech/6055020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Url < ActiveRecord::Base | |
def find_link(url) | |
link = link_finder(url) | |
EM::Run { | |
link.callback { | |
p "done" | |
} | |
} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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