Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Gist for Kthxbye readme
# dummy job class
class MyJob
def self.perform(data)
puts "Do something with #{data}"
data.gsub(/hello/i, "Goodbye")
# setup options, then connect
Kthxbye::Config.setup(:redis_server => 'localhost', :redis_port => 8080)
# 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)
# inits with queue
worker ="jobs")
# connects to queue and runs jobs found there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment