rgossip2 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,7 +133,7 @@ module RGossip2
133
133
 
134
134
  node.start_timer if @running
135
135
 
136
- callback(:add, address, nil, nil)
136
+ callback(:add, address, nil, nil, nil)
137
137
  }
138
138
  }
139
139
  end
@@ -155,7 +155,7 @@ module RGossip2
155
155
  node = @dead_list.delete(address)
156
156
  node.stop_timer if node
157
157
 
158
- callback(:delete, address, nil, nil)
158
+ callback(:delete, address, nil, nil, nil)
159
159
  }
160
160
  }
161
161
  end
@@ -18,9 +18,9 @@ module RGossip2
18
18
  end
19
19
 
20
20
  # 各種ハンドラプロキシメソッド
21
- def callback(action, address, timestamp, data)
21
+ def callback(action, address, timestamp, data, old_data)
22
22
  if @context.callback_handler
23
- __proc_yield_protect__(@context.callback_handler, action, address, timestamp, data)
23
+ __proc_yield_protect__(@context.callback_handler, action, address, timestamp, data, old_data)
24
24
  end
25
25
  end
26
26
 
data/lib/rgossip2/node.rb CHANGED
@@ -51,7 +51,7 @@ module RGossip2
51
51
  }
52
52
 
53
53
  # 破棄時の処理をコールバック
54
- callback(:delete, @address, @timestamp, @data)
54
+ callback(:delete, @address, @timestamp, @data, @data)
55
55
  end
56
56
  end
57
57
 
@@ -111,10 +111,11 @@ module RGossip2
111
111
  #debug("The node was updated: address=#{address} timestamp=#{timestamp}")
112
112
 
113
113
  node.timestamp = timestamp
114
+ old_data = node.data
114
115
  node.data = data
115
116
  node.reset_timer
116
117
 
117
- callback(:update, address, timestamp, data)
118
+ callback(:update, address, timestamp, data, old_data)
118
119
  end
119
120
  elsif (node = @dead_list.synchronize { @dead_list[address] })
120
121
  # デッドリストに見つかった場合
@@ -126,10 +127,16 @@ module RGossip2
126
127
  #debug("Node revived: address=#{address} timestamp=#{timestamp}")
127
128
 
128
129
  @dead_list.delete(address)
130
+
131
+ # データの更新を忘れずに
132
+ node.timestamp = timestamp
133
+ old_data = node.data
134
+ node.data = data
135
+
129
136
  @node_list[address] = node
130
137
  node.start_timer
131
138
 
132
- callback(:comeback, address, timestamp, data)
139
+ callback(:comeback, address, timestamp, data, old_data)
133
140
  end
134
141
  }
135
142
  else
@@ -142,7 +149,7 @@ module RGossip2
142
149
  @node_list[address] = node
143
150
  node.start_timer
144
151
 
145
- callback(:add, address, timestamp, data)
152
+ callback(:add, address, timestamp, data, data)
146
153
  end
147
154
  end
148
155
  end # merge_lists
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgossip2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - winebarrel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-13 00:00:00 Z
18
+ date: 2011-11-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: msgpack