goat 0.3.47 → 0.3.48
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.
- data/bin/channel-srv +1 -1
- data/bin/state-srv +36 -23
- data/goat.gemspec +1 -1
- data/lib/goat.rb +8 -7
- data/lib/goat/common.rb +14 -2
- data/lib/goat/extn.rb +10 -0
- data/lib/goat/goat.js +18 -15
- data/lib/goat/state-srv.rb +2 -1
- metadata +4 -4
data/bin/channel-srv
CHANGED
@@ -155,7 +155,7 @@ def usage
|
|
155
155
|
end
|
156
156
|
|
157
157
|
OptionParser.new do |opts|
|
158
|
-
opts.on('-pMANDATORY', Integer) {|p| $port =
|
158
|
+
opts.on('-pMANDATORY', Integer) {|p| $port = r}
|
159
159
|
opts.on('-HMANDATORY', String) {|h| $host = h}
|
160
160
|
opts.on('-SMANDATORY', String) {|h| $statesrv_host = h}
|
161
161
|
opts.on('-sMANDATORY', Integer) {|p| $statesrv_port = p}
|
data/bin/state-srv
CHANGED
@@ -13,6 +13,7 @@ $:.unshift(File.join(File.dirname(__FILE__), '../lib'))
|
|
13
13
|
|
14
14
|
require 'goat/common'
|
15
15
|
require 'goat/net-common'
|
16
|
+
require 'goat/extn'
|
16
17
|
|
17
18
|
module Goat
|
18
19
|
module StateSrv
|
@@ -190,7 +191,8 @@ module Goat
|
|
190
191
|
end
|
191
192
|
|
192
193
|
def memusage
|
193
|
-
|
194
|
+
Goat.logd "Components in memory: #{@components_by_id.values.count}"
|
195
|
+
@components_by_id.values.map(&:cls).tally.sort.each {|k, v| Goat.logd "#{k} - #{v}"}
|
194
196
|
end
|
195
197
|
end
|
196
198
|
|
@@ -236,6 +238,10 @@ module Goat
|
|
236
238
|
updates.map(&:removed).flatten.each{|c| @registry.delete_component(c)}
|
237
239
|
|
238
240
|
updates.each {|u| handle_component_update(txn, u)}
|
241
|
+
if txn
|
242
|
+
txn_complete_update(pgid, txn)
|
243
|
+
end
|
244
|
+
|
239
245
|
send_updates(pgid)
|
240
246
|
|
241
247
|
{'type' => 'update_ack', 'components' => updates.map{|u| u.skel.id}}
|
@@ -260,7 +266,8 @@ module Goat
|
|
260
266
|
if c = @registry.find_id(msg['id'])
|
261
267
|
c.to_hash
|
262
268
|
else
|
263
|
-
|
269
|
+
Goat.logw "Couldn't find component #{msg['id']}"
|
270
|
+
{} # if we return nil, no resp will be sent
|
264
271
|
end
|
265
272
|
end
|
266
273
|
|
@@ -289,17 +296,18 @@ module Goat
|
|
289
296
|
msgs = []
|
290
297
|
|
291
298
|
need.each do |u|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
299
|
+
if u.is_a?(ComponentUpdate)
|
300
|
+
msgs << {
|
301
|
+
'pgid' => pgid,
|
302
|
+
'class' => u.skel.cls,
|
303
|
+
'id' => u.skel.id,
|
304
|
+
'type' => 'component_updated',
|
305
|
+
'updates' => u.mutations,
|
306
|
+
'version' => u.version
|
307
|
+
}
|
308
|
+
elsif u.is_a?(TxnCompleteUpdate)
|
309
|
+
msgs << {'type' => 'txn_complete', 'txn' => u.txn, 'version' => u.version}
|
310
|
+
end
|
303
311
|
end
|
304
312
|
|
305
313
|
send_message(chsrv_id, 'page_updated', {'pgid' => pgid, 'messages' => msgs}) unless msgs.empty?
|
@@ -329,6 +337,11 @@ module Goat
|
|
329
337
|
end
|
330
338
|
end
|
331
339
|
|
340
|
+
def txn_complete_update(pgid, txn)
|
341
|
+
@registry.incr_page_version(pgid)
|
342
|
+
@registry.add_update(pgid, txn, TxnCompleteUpdate.new(@registry.page_version(pgid), txn))
|
343
|
+
end
|
344
|
+
|
332
345
|
def page_connected(msg)
|
333
346
|
ensure_keys(msg, %w{pgid chsrv version})
|
334
347
|
|
@@ -401,6 +414,16 @@ module Goat
|
|
401
414
|
if ObjectSpace.respond_to?(:live_objects)
|
402
415
|
Goat.logd "Done. Live objects: #{ObjectSpace.live_objects}"
|
403
416
|
end
|
417
|
+
|
418
|
+
maybe_print_statistics
|
419
|
+
end
|
420
|
+
|
421
|
+
def maybe_print_statistics
|
422
|
+
@last_printed ||= Time.now
|
423
|
+
if Time.now - @last_printed > 2
|
424
|
+
Delegate.registry.memusage
|
425
|
+
end
|
426
|
+
@last_printed = Time.now
|
404
427
|
end
|
405
428
|
end
|
406
429
|
|
@@ -428,16 +451,6 @@ module Goat
|
|
428
451
|
else
|
429
452
|
$stderr.puts "Delegate doesn't respond to #{type.inspect}"
|
430
453
|
end
|
431
|
-
|
432
|
-
maybe_print_statistics
|
433
|
-
end
|
434
|
-
|
435
|
-
def maybe_print_statistics
|
436
|
-
@last_printed ||= Time.now
|
437
|
-
if Time.now - @last_printed > 10
|
438
|
-
Delegate.registry.memusage
|
439
|
-
end
|
440
|
-
@last_printed = Time.now
|
441
454
|
end
|
442
455
|
|
443
456
|
def unbind
|
data/goat.gemspec
CHANGED
data/lib/goat.rb
CHANGED
@@ -32,15 +32,16 @@ require 'goat/dynamic'
|
|
32
32
|
|
33
33
|
$verbose ||= ARGV.include?('-v')
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
unless defined?(Profile)
|
36
|
+
class Profile
|
37
|
+
# TODO make sure not already defined
|
38
|
+
def self.in(*args); end
|
39
|
+
def self.out(*args); end
|
40
|
+
def self.request_start(*args); end
|
41
|
+
def self.request_end(*args); end
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
|
-
|
44
45
|
class String
|
45
46
|
def prefix_ns(ns)
|
46
47
|
self.gsub(/^%(.+)$/, "#{ns}_\\1")
|
data/lib/goat/common.rb
CHANGED
@@ -53,9 +53,21 @@ module Goat
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
class
|
57
|
-
attr_reader :skel, :mutations, :added, :removed
|
56
|
+
class PageUpdate
|
58
57
|
attr_accessor :version
|
58
|
+
end
|
59
|
+
|
60
|
+
class TxnCompleteUpdate < PageUpdate
|
61
|
+
attr_reader :txn
|
62
|
+
|
63
|
+
def initialize(version, txn)
|
64
|
+
@version = version
|
65
|
+
@txn = txn
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class ComponentUpdate < PageUpdate
|
70
|
+
attr_reader :skel, :mutations, :added, :removed
|
59
71
|
|
60
72
|
def initialize(skel, mutations, added, removed)
|
61
73
|
@skel = skel
|
data/lib/goat/extn.rb
CHANGED
data/lib/goat/goat.js
CHANGED
@@ -130,18 +130,23 @@ Goat.RT = {
|
|
130
130
|
Goat.loadComponents();
|
131
131
|
}
|
132
132
|
|
133
|
-
function updateReceived(
|
134
|
-
var
|
135
|
-
var
|
136
|
-
var
|
137
|
-
|
138
|
-
if(
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
133
|
+
function updateReceived(u, t) {
|
134
|
+
var version = u.version;
|
135
|
+
var updates = u.updates;
|
136
|
+
var txn = u.txn;
|
137
|
+
|
138
|
+
if(u.version == rt.version + 1) {
|
139
|
+
if(t == 'component_updated') {
|
140
|
+
$(updates).each(function(_,up) {
|
141
|
+
rt.consecutiveFailures = 0;
|
142
|
+
applyUpdate(up);
|
143
|
+
});
|
144
|
+
} else if(t == 'txn_complete') {
|
145
|
+
completeTxn(txn);
|
146
|
+
}
|
147
|
+
|
143
148
|
rt.version++;
|
144
|
-
} else if(
|
149
|
+
} else if(u.version <= rt.version) {
|
145
150
|
rt.consecutiveFailures = 0;
|
146
151
|
// fine, we already have this
|
147
152
|
} else {
|
@@ -399,8 +404,8 @@ $.extend(Goat, {
|
|
399
404
|
Goat.log('messageReceived', m.type, m);
|
400
405
|
|
401
406
|
var t = m['type'];
|
402
|
-
if(t == 'component_updated') {
|
403
|
-
Goat.RT.updateReceived(m);
|
407
|
+
if(t == 'component_updated' || t == 'txn_complete') {
|
408
|
+
Goat.RT.updateReceived(m, t);
|
404
409
|
} else if(t == 'redirect') {
|
405
410
|
if(m["location"]) {
|
406
411
|
Goat.log('Redirecting to ' + m['location']);
|
@@ -412,8 +417,6 @@ $.extend(Goat, {
|
|
412
417
|
} else if(t == 'page_expired') {
|
413
418
|
alert("Due to inactivity, you'll need to refresh this page.");
|
414
419
|
Goat.setPageDead();
|
415
|
-
} else if(t == 'txn_complete') {
|
416
|
-
Goat.RT.completeTxn(m['txn']);
|
417
420
|
} else if(t == 'alert') {
|
418
421
|
this.showAlert(m);
|
419
422
|
} else {
|
data/lib/goat/state-srv.rb
CHANGED
@@ -37,7 +37,8 @@ module Goat
|
|
37
37
|
|
38
38
|
def self.fetch_component(id)
|
39
39
|
resp = send_message('fetch_component', {'id' => id}, true)
|
40
|
-
|
40
|
+
skelhash = JSON.load(resp)['response']
|
41
|
+
skelhash.empty? ? nil : ComponentSkeleton.from_hash(skelhash)
|
41
42
|
end
|
42
43
|
|
43
44
|
def self.component_updated(txn, pgid, update)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 115
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 48
|
10
|
+
version: 0.3.48
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Collison
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-17 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|