Module: ZkService
- Included in:
- Publisher, Vendor
- Defined in:
- lib/zk_service.rb,
lib/zk_service/version.rb
Defined Under Namespace
Modules: Publisher
Classes: InvalidZookeeperConfig, NoAvailableZookeeper, Vendor, ZkServicePublisherError, ZkServiceVendorError
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Method Summary
collapse
Class Method Details
.check_namespaces(zookeeper_namespace) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/zk_service.rb', line 17
def self.check_namespaces(zookeeper_namespace)
zookeeper_namespace ||= "/"
if zookeeper_namespace && !zookeeper_namespace.start_with?("/")
raise InvalidZookeeperConfig.new("Zookeeper namespace should start with '/'")
end
zookeeper_namespace
end
|
8
9
10
11
12
13
14
15
|
# File 'lib/zk_service.rb', line 8
def self.configure( h, p )
hostkey, port = h, p
zookeeper_server_addresses = []
zookeeper_server_addresses << "#{h}:#{p}"
end
|
.create_connection(zookeeper_server_addresses) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/zk_service.rb', line 25
def self.create_connection(zookeeper_server_addresses)
begin
tryable = zookeeper_server_addresses.choice
Zookeeper.new( tryable )
rescue Exception => e
zookeeper_server_addresses.shift
if zookeeper_server_addresses.empty?
raise NoAvailableZookeeper.new else
create_connection(zookeeper_server_addresses) end
end
end
|