seapig-server 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/seapig-server +19 -19
- data/lib/seapig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc1dfab75d86ebb7523b8c222a9ddddc04f0f964
|
4
|
+
data.tar.gz: 70a80882af69611cb10a40c62194c6d6ef1cddc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25f0d0f2af7aa1047e7e8b27b57a81f8694557b9e6df353e56ed6386fe1dd9ab82570570cf438d74e0d5873971b95a214f3937ccceacf08c270fd5e88b115e5
|
7
|
+
data.tar.gz: 022fb4c73f3151623c89fc9fbe754d3e995a93b27f131d7cc957980326789664f72c1572bedeaae04a2aa6894851bc7e16ea8651cadac17616ec19675c856b3e
|
data/bin/seapig-server
CHANGED
@@ -65,6 +65,7 @@ class SeapigObject
|
|
65
65
|
|
66
66
|
def self.gc
|
67
67
|
used_object_ids = Set.new
|
68
|
+
Client.all.each { |client| used_object_ids << client.producing if client.producing } #objects currently being produced
|
68
69
|
Client.all.each { |client| used_object_ids.merge(client.consumes.map { |object| object.id }) } #objects with direct consuments (no pattern matching)
|
69
70
|
@@objects_by_id.values.each { |object| used_object_ids << object.id if Client.all.find { |client| client.produces.include?(object.id) } and Client.all.find { |client| client.consumes.find { |consumed| consumed.id.starexp? and object.id =~ consumed.id.starexp } } } #objects having producers AND wildcard consuments
|
70
71
|
@@objects_by_id.values.each { |object| object.version.keys.each { |key| used_object_ids << key } if object.version.kind_of?(Hash) } # objects that others depend on
|
@@ -80,11 +81,11 @@ class SeapigObject
|
|
80
81
|
|
81
82
|
|
82
83
|
def patch(patch, value, from_version, new_version)
|
83
|
-
print "Patching:\n version:"+@version.inspect+"\n
|
84
|
+
print "Patching:\n version:"+@version.inspect+"\n from_version: "+from_version.inspect+"\n new_version: "+new_version.inspect+"\n patch_size: "+(patch and patch.size.to_s or "nil")+"\n --> "
|
84
85
|
if from_version == @version or from_version == 0
|
85
86
|
puts 'clean'
|
86
87
|
if value and @stall_after
|
87
|
-
puts '
|
88
|
+
puts ' UNSTALL'
|
88
89
|
@version = @stall_after
|
89
90
|
@stall_after = nil
|
90
91
|
end
|
@@ -94,11 +95,11 @@ class SeapigObject
|
|
94
95
|
begin
|
95
96
|
Hana::Patch.new(patch).apply(@object) if patch
|
96
97
|
rescue Exception => e
|
97
|
-
puts "Patching failed!\n
|
98
|
+
puts "Patching failed!\n Old object: "+old_object.inspect+"\n Patch: "+patch.inspect
|
98
99
|
raise e
|
99
100
|
end
|
100
101
|
if value == false and not @stall_after
|
101
|
-
puts '
|
102
|
+
puts ' STALL'
|
102
103
|
@stall_after = old_version
|
103
104
|
end
|
104
105
|
@object.merge!(value) if value
|
@@ -120,13 +121,14 @@ class SeapigObject
|
|
120
121
|
def upload(client, old_version, old_object, patch = nil)
|
121
122
|
return false if @stall_after
|
122
123
|
return false if not client.consumes.find { |object| (object == self) or self.matches?(object.id) }
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
124
|
+
json = JSON.dump(
|
125
|
+
action: 'object-update',
|
126
|
+
id: @id,
|
127
|
+
old_version: old_version,
|
128
|
+
new_version: @version,
|
129
|
+
patch: (patch or JsonDiff.generate(old_object, @object)))
|
130
|
+
puts "Sending %8iB %s to "%[json.size, self.id, client.id]
|
131
|
+
client.socket.send json
|
130
132
|
end
|
131
133
|
|
132
134
|
|
@@ -276,12 +278,10 @@ EM.run {
|
|
276
278
|
client.producer_unregister(message['pattern'])
|
277
279
|
when 'object-patch'
|
278
280
|
fail unless message['id'] and message['new_version'] and message['old_version']
|
281
|
+
client.release(object)
|
279
282
|
SeapigObject.gc
|
280
|
-
if SeapigObject.all.include?(object) # ignoring objects nobody listens to
|
281
|
-
|
282
|
-
client.release(object)
|
283
|
-
SeapigObject.all.each { |object| Client.all.find { |client| client.assign(object) } }
|
284
|
-
end
|
283
|
+
object.patch(message['patch'], message['value'], message['old_version'], message['new_version']) if SeapigObject.all.include?(object) # ignoring objects nobody listens to
|
284
|
+
SeapigObject.all.each { |object| Client.all.find { |client| client.assign(object) } }
|
285
285
|
when 'object-consumer-register'
|
286
286
|
fail unless message['id']
|
287
287
|
client.consumer_register(object)
|
@@ -296,9 +296,9 @@ EM.run {
|
|
296
296
|
end
|
297
297
|
processing_times << (Time.new.to_f - started_at.to_f)
|
298
298
|
processing_times_sum += processing_times[-1]
|
299
|
-
puts "Clients:\n"+Client.all.map { |client| "
|
300
|
-
puts "Objects:\n"+SeapigObject.all.map { |object| "
|
301
|
-
puts "Processing:\n
|
299
|
+
puts "Clients:\n"+Client.all.map { |client| " %-20s produces:%s consumes:%s"%[client.id,client.produces.inspect,client.consumes.map { |obj| obj.id }] }.join("\n")+"\n"
|
300
|
+
puts "Objects:\n"+SeapigObject.all.map { |object| " %s"%[object.inspect] }.join("\n")+"\n"
|
301
|
+
puts "Processing:\n time: %.3fs\n count: %i\n average: %.3fs\n total: %.3fs"%[processing_times[-1], processing_times.size, processing_times_sum / processing_times.size, processing_times_sum]
|
302
302
|
STDOUT.flush
|
303
303
|
}
|
304
304
|
|
data/lib/seapig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seapig-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yunta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket-eventmachine-server
|