Class: Beanpool

Inherits:
Object
  • Object
show all
Defined in:
lib/beanpool.rb,
lib/beanpool/version.rb,
lib/beanpool/connections.rb

Defined Under Namespace

Classes: Connections

Constant Summary collapse

VERSION =
"0.1.7"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip_array, debug = false) ⇒ Beanpool

Returns a new instance of Beanpool.



8
9
10
11
# File 'lib/beanpool.rb', line 8

def initialize(ip_array, debug = false)
  raise 'Beanpool must be initialized with an array of IP addresses' unless ip_array.is_a?(Array) && !ip_array.empty?
  @connections = Beanpool::Connections.new(ip_array, debug)
end

Instance Attribute Details

#connectionsObject (readonly)

Returns the value of attribute connections.



6
7
8
# File 'lib/beanpool.rb', line 6

def connections
  @connections
end

Instance Method Details

#closeObject



21
22
23
# File 'lib/beanpool.rb', line 21

def close
  @connections.close
end

#get(timeout = nil, tube_name = 'default') ⇒ Object



17
18
19
# File 'lib/beanpool.rb', line 17

def get(timeout = nil, tube_name = 'default')
  @connections.get_job_from_tube(timeout, tube_name)
end

#get_ready_by_tube(name) ⇒ Object



40
41
42
# File 'lib/beanpool.rb', line 40

def get_ready_by_tube(name)
  @connections.stats(name, :current_jobs_ready)
end

#get_stat_by_tube(tube_name, stat_name) ⇒ Object



36
37
38
# File 'lib/beanpool.rb', line 36

def get_stat_by_tube(tube_name, stat_name)
  @connections.stats(tube_name, stat_name)
end

#put(body, options) ⇒ Object



13
14
15
# File 'lib/beanpool.rb', line 13

def put(body, options)
  @connections.put_job_to_tube(body, options)
end

#sizeObject



44
45
46
# File 'lib/beanpool.rb', line 44

def size
  @connections.stats('default', :current_jobs_ready)
end

#statsObject



25
26
27
28
29
30
# File 'lib/beanpool.rb', line 25

def stats
  { not_implemented: true }
rescue => ex
  BlitlineLogger.log(ex)
  return {}
end

#use_tube(tube_name) ⇒ Object



32
33
34
# File 'lib/beanpool.rb', line 32

def use_tube(tube_name)
  @connections.use_tube(tube_name)
end