Project

qube

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby HTTP-client for the Message Queue based on Tarantool
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

qube-ruby

Сlient for the Tarantool Queue for Ruby over HTTP via persistent connection. Currently supported is take, put, ack and will continue to add as needed.

require 'qube'

Qube.setup do |c|
  c.api_uri    = 'http://localhost:5672/api/v1/'
  c.api_token  = '77c04ced3f915240d0c5d8d5819f84c7' # md5 -s qube
end

queue = Qube::Queue.new
pp queue.tube_exist?('welcome_mail') # => false

tube = queue.create_tube(name: 'welcome_mail', type: 'fifo')
pp tube # => #<Qube::Tube:0x00007fe68b159b80 ...

put_status = tube.put({ name: 'Ivan Ivanov', locale: 'ru', email: 'ivan@localhost.dev' })
pp put_status # => true

task = tube.take
pp task
# =>
# {
#  "task_id" => 0,
#     "data" => {
#       "email" => "ivan@localhost.dev",
#        "name" => "Ivan Ivanov",
#      "locale" => "ru"
#  }
# }

ack_status = tube.ack task.dig('task_id')
pp ack_status
# => true

# Taking the each task, processing and ack it in the one step
tube.each_task do |task|
  pp task
end

delete_status = queue.delete_tube('welcome_mail')
pp delete_status
# => true