Module: Beanqueue
- Defined in:
- lib/beanqueue.rb
Constant Summary collapse
- VERSION =
'0.1.2'
Class Method Summary collapse
Class Method Details
.connect(nodes) ⇒ Object
16 17 18 |
# File 'lib/beanqueue.rb', line 16 def connect(nodes) @connection = Beanstalk::Pool.new(nodes.is_a?(Array) ? nodes : [nodes]) end |
.get_params(yaml_path) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/beanqueue.rb', line 7 def get_params(yaml_path) hash = YAML.load(open(yaml_path)) if hash['nodes'] hash['nodes'].map { |node| "#{node['host']}:#{node['port']}" } else "#{hash['host']}:#{hash['port']}" end end |
.push(name, args = {}, opts = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/beanqueue.rb', line 20 def push(name, args={}, opts={}) args['__fork__'] = opts[:fork] if opts[:fork] @connection.use name.to_s.gsub('_', '.') @connection.yput args, (opts[:priority] || 65536), [0, opts[:delay].to_i].max, (opts[:timeout] || 120) end |