Created
September 1, 2010 16:06
-
-
Save plukevdh/560927 to your computer and use it in GitHub Desktop.
Gist for Kthxbye readme
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
# dummy job class | |
class MyJob | |
def self.perform(data) | |
puts "Do something with #{data}" | |
data.gsub(/hello/i, "Goodbye") | |
end | |
end | |
# setup options, then connect | |
Kthxbye::Config.setup(:redis_server => 'localhost', :redis_port => 8080) | |
Kthxbye.connect | |
# each enqueued job returns a unique id to poll with | |
unique_id = Kthxbye.enqueue("jobs", MyJob, "Hello World") | |
# ... code code code ... | |
# polls queue every 5 seconds | |
computed_value = Kthxbye.poll("jobs", unique_id, 5) |
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
# inits with queue | |
worker = Kthxbye::Worker.new("jobs") | |
# connects to queue and runs jobs found there | |
worker.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment