Rest API Usage
REST API
How do I use AllQ now?

Example
Last updated
Was this helpful?
REST API

Last updated
Was this helpful?
Was this helpful?
gem install allq_restrequire 'allq_rest'
require 'base64'
base_client = Allq::ApiClient.new(Allq::Configuration.new)
@worker_client = Allq::ActionsApi.new(base_client)
@admin_client = Allq::AdminApi.new(base_client)
def done(job)
@worker_client.job_delete(job.id)
end
def stats
@admin_client.stats_get
end
def put_job(tube_name, data)
job = build_new_job(data, { tube_name: tube_name})
@worker_client.job_post(job)
end
def get_job(tube_name)
@worker_client.job_get(tube_name)
end
def build_new_job(data, options)
ttl = options[:ttl] || 600
tube_name = options[:tube_name] || 'default'
delay = options[:delay] || 0
parent_id = options[:parent_id]
new_job = Allq::NewJob.new(tube: tube_name,
body: data,
ttl: ttl,
delay: delay,
priority: 5,
parent_id: parent_id)
new_job
end
# Put job on queue
put_job("my_tube_name", "Some data I want to push to queue")
# Get job off queue
job = get_job("my_tube_name")
# Output data (allq_client gem base64 encodes body)
puts Base64.decode64(job.body)
# Mark job as done
done(job)
# Example of stats from server
puts "Stats:", statsruby test.rb