Class: Hermann::Discovery::Zookeeper::ZkGemImpl
- Inherits:
-
Object
- Object
- Hermann::Discovery::Zookeeper::ZkGemImpl
- Defined in:
- lib/hermann/discovery/zookeeper.rb
Overview
The ZkGemImpl class is an implementation of simple broker discovery using the ‘zk` gem if it is available
Class Method Summary collapse
Instance Method Summary collapse
- #brokers(timeout = 0) ⇒ Object
-
#initialize(zks) ⇒ ZkGemImpl
constructor
A new instance of ZkGemImpl.
Constructor Details
#initialize(zks) ⇒ ZkGemImpl
Returns a new instance of ZkGemImpl.
75 76 77 |
# File 'lib/hermann/discovery/zookeeper.rb', line 75 def initialize(zks) @zookeepers = zks end |
Class Method Details
.usable? ⇒ Boolean
66 67 68 69 70 71 72 73 |
# File 'lib/hermann/discovery/zookeeper.rb', line 66 def self.usable? begin require 'zk' return true rescue LoadError return false end end |
Instance Method Details
#brokers(timeout = 0) ⇒ Object
79 80 81 82 83 |
# File 'lib/hermann/discovery/zookeeper.rb', line 79 def brokers(timeout=0) ZK.open(@zookeepers, {:timeout => timeout}) do |zk| return fetch_brokers(zk) end end |