reminder-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6b36225cc57fa35c8e9dd456c6c489bc8e03ecf
4
- data.tar.gz: 82c8267b349cfe3f15521bc0b42819b764a40836
3
+ metadata.gz: 5e4b20dadedd3af348a6f852daa7d2259dcf7b16
4
+ data.tar.gz: e6d69823fb71b2f49a59c03c941cfad7935376ad
5
5
  SHA512:
6
- metadata.gz: 5e67bc877e9de398c3b53bc6f6d6de4d0f0c025f20a5228075644ffb00d4d49eafe1a3eaf2c19e1a275c422773ce221e505d89a8994c945c0488208acd24545d
7
- data.tar.gz: 860550792871e6991ecfa43d29caeeb4438982e9577a21967774a31b80a8529207ce13bbdc2d4814c9bc6b48592d5517e5520865e332a2cf9bc877fa1109aff4
6
+ metadata.gz: a5716c61a67bd93fe1a5055f074491d04a0cc5c3a6066f850eb92544e4836f44d07793e78d5c5a0c3f2de0b8bfcad5adce4f597a1b863cc838521152393d3457
7
+ data.tar.gz: 3d0be3d23fb5c46d64bb6bbf1b1c78542e7cb02efe89d68bd7923dad9072cba6ed442896012f2662b7f5f53d09395365e682f54d8f9302447281a69df5d2bad4
@@ -4,6 +4,18 @@ require 'zookeeper'
4
4
  require 'eventmachine'
5
5
  require 'zk'
6
6
 
7
+ # Public: Create a Zk instence and connect, the following
8
+ # relaying on it, it will block until connected successfully.
9
+ #
10
+ # options - The import hash include zk_address
11
+ #
12
+ # Examples
13
+ #
14
+ # Zoo.new({ :zk_address => "192.168.1.172:2181" })
15
+ # Zoo.new({ zk_address: "192.168.1.172:2181" })
16
+ # # => nil
17
+ #
18
+ # Returns a Zoo instance.
7
19
  class Zoo
8
20
  def initialize(options)
9
21
  p "start connect to #{options[:zk_address]}"
@@ -22,8 +34,20 @@ class Zoo
22
34
  puts "init succ #{@zk}"
23
35
  end
24
36
 
25
- # server found server part
26
- # option temporarily has one param ip_port .eg "192.168.3.1:2222"
37
+
38
+ # Public: zk server found server part, and it will create a ephemeral path
39
+ # with current server's service ip, address, or so on.
40
+ #
41
+ # option - The hash :ip_port -> service address .eg "192.168.3.1:2222".
42
+ # child(option) - The sub-path name.
43
+ #
44
+ # Examples
45
+ #
46
+ # server_found_server({ server_found_base_path = "/stat-server" })
47
+ # server_found_server({ server_found_base_path = "/stat-server" }, "child")
48
+ # # => nil
49
+ #
50
+ # Returns nil.
27
51
  def server_found_server(option, child = 'default')
28
52
  #fork do
29
53
  # @zk.reopen()
@@ -32,7 +56,20 @@ class Zoo
32
56
  #end
33
57
  end
34
58
 
35
- # server found client part
59
+
60
+ # Public: server found client part.
61
+ #
62
+ # server_path - The String (zk's path) to be watched.
63
+ # block - The callback to be call when the server_path to be watched changed.
64
+ #
65
+ # Examples
66
+ #
67
+ # server_found_client('/stat-service'){ | iplist, load_balance |
68
+ # puts iplist
69
+ # puts load_balance
70
+ # }
71
+ # # => nil
72
+ #
36
73
  def server_found_client(server_path, &block)
37
74
  puts "zk server_found start watching on #{server_path}"
38
75
  relist = @zk.children(server_path, :watch => true)
@@ -57,6 +94,18 @@ class Zoo
57
94
  end
58
95
  end
59
96
 
97
+ # Private: Internal function, get each sub path's data.
98
+ #
99
+ # server_path - The String to be duplicated.
100
+ # relist - The Integer number of times to duplicate the text.
101
+ #
102
+ # Examples
103
+ #
104
+ # get_ip_from_server('/server-stat', ['default0000001', 'default0000002'
105
+ # , 'default0000003'])
106
+ # # => ['192.168.2.220:2222', '192.168.2.220:3333', '192.168.2.222:4444']
107
+ #
108
+ # Returns the ip list.
60
109
  def get_ip_from_server(server_path, relist)
61
110
  list = []
62
111
  relist.each { |child|
@@ -69,7 +118,22 @@ class Zoo
69
118
  list.uniq
70
119
  end
71
120
 
72
- def server_config_client(config_path, service, group, &block)
121
+ # Public: The serverConfig client part
122
+ #
123
+ # config_path - The config_path of zk tobe watched.
124
+ # group - The group of the service
125
+ # block - The callback to be call when the config_path to be watched changed.
126
+ #
127
+ #
128
+ # Examples
129
+ #
130
+ # server_config_client('/config/server-stat', 'stat-service', 1){ |configdata|
131
+ # puts configdata
132
+ # }
133
+ # # => nil
134
+ #
135
+ # Returns nil.
136
+ def server_config_client(config_path, group, &block)
73
137
  puts "zk server_config start watching on #{config_path}"
74
138
 
75
139
  # get server config for the first time
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reminder-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - caorong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-19 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zk
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project:
60
- rubygems_version: 2.2.0
60
+ rubygems_version: 2.2.2
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: A zookeeper client wrapper provide serverfound and serverconfig.