Class: Beanpool
- Inherits:
-
Object
- Object
- Beanpool
- 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
-
#connections ⇒ Object
readonly
Returns the value of attribute connections.
Instance Method Summary collapse
- #close ⇒ Object
- #get(timeout = nil, tube_name = 'default') ⇒ Object
- #get_ready_by_tube(name) ⇒ Object
- #get_stat_by_tube(tube_name, stat_name) ⇒ Object
-
#initialize(ip_array, debug = false) ⇒ Beanpool
constructor
A new instance of Beanpool.
- #put(body, options) ⇒ Object
- #size ⇒ Object
- #stats ⇒ Object
- #use_tube(tube_name) ⇒ Object
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
#connections ⇒ Object (readonly)
Returns the value of attribute connections.
6 7 8 |
# File 'lib/beanpool.rb', line 6 def connections @connections end |
Instance Method Details
#close ⇒ Object
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, ) @connections.put_job_to_tube(body, ) end |
#size ⇒ Object
44 45 46 |
# File 'lib/beanpool.rb', line 44 def size @connections.stats('default', :current_jobs_ready) end |
#stats ⇒ Object
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 |