scales-monitor 0.0.1.beta.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ class App.Log extends Spine.Controller
7
7
  super
8
8
  @render()
9
9
  @bindEvents()
10
+ @changed = false
10
11
  setInterval =>
11
12
  @eventsDiv.animate({ scrollTop: @eventsDiv[0].scrollHeight }, 500)
12
13
  , 1000
@@ -55,4 +56,5 @@ class App.Log extends Spine.Controller
55
56
  else
56
57
  out += "<br/>&nbsp;&nbsp;&nbsp; -> #{item} = #{data}"
57
58
 
58
- @eventsDiv.append out
59
+ @eventsDiv.append out
60
+ @changed = true
@@ -8,10 +8,20 @@ class App.Resources extends Spine.Controller
8
8
  constructor: ->
9
9
  super
10
10
  [@resources, @partials, @servers] = [{}, {}, {}]
11
+ [@resourcesChanged, @partialsChanged] = [false, false]
11
12
  @colors = {}
12
13
  @bindColors()
13
14
  @render()
14
15
  @bindEvents()
16
+ setInterval =>
17
+ if @resourcesChanged
18
+ @resourcesChanged = false
19
+ @renderResources(@resources, @resourcesDiv)
20
+
21
+ if @partialsChanged
22
+ @partialsChanged = false
23
+ @renderResources(@partials, @partialsDiv)
24
+ , 200
15
25
 
16
26
  activate: ->
17
27
  @el.addClass("active")
@@ -40,27 +50,27 @@ class App.Resources extends Spine.Controller
40
50
 
41
51
  Spine.bind 'push_resource', (resource) =>
42
52
  @resources[resource.path] = resource
43
- @renderResources(@resources, @resourcesDiv)
53
+ @resourcesChanged = true
44
54
 
45
55
  Spine.bind 'destroy_resource', (resource) =>
46
56
  delete @resources[resource.path]
47
- @renderResources(@resources, @resourcesDiv)
57
+ @resourcesChanged = true
48
58
 
49
59
  Spine.bind 'push_partial', (partial) =>
50
60
  @partials[partial.path] = partial
51
- @renderResources(@partials, @partialsDiv)
61
+ @partialsChanged = true
52
62
 
53
63
  Spine.bind 'destroy_partial', (partial) =>
54
64
  delete @partials[partial.path]
55
- @renderResources(@partials, @partialsDiv)
65
+ @partialsChanged = true
56
66
 
57
67
  Spine.bind 'server_started', (server) =>
58
68
  @servers[server.id] = server
59
- @renderResources(@resources, @resourcesDiv)
69
+ @resourcesChanged = true
60
70
 
61
71
  Spine.bind 'server_stopped', (server) =>
62
72
  delete @servers[server.id]
63
- @renderResources(@resources, @resourcesDiv)
73
+ @resourcesChanged = true
64
74
 
65
75
  render: ->
66
76
  @html JST['app/views/resources'](@)
@@ -91,6 +101,7 @@ class App.Resources extends Spine.Controller
91
101
  div.html out
92
102
  div.tooltip({ selector: "a" })
93
103
  @renderContentTypes()
104
+
94
105
 
95
106
  processContentTypes: ->
96
107
  formats = {}
@@ -23,7 +23,9 @@
23
23
 
24
24
  <div class="span4">
25
25
  <div class="page-header"><h1>Content Types</h1></div>
26
- <div id="content_types"></div>
26
+ <div id="content_types">
27
+ <div class="well dark-grey pagination-centered"><h2 class="white">0</h2></div>
28
+ </div>
27
29
  </div>
28
30
 
29
31
  </div>
@@ -4469,6 +4469,7 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
4469
4469
  Log.__super__.constructor.apply(this, arguments);
4470
4470
  this.render();
4471
4471
  this.bindEvents();
4472
+ this.changed = false;
4472
4473
  setInterval(function() {
4473
4474
  return _this.eventsDiv.animate({
4474
4475
  scrollTop: _this.eventsDiv[0].scrollHeight
@@ -4549,7 +4550,8 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
4549
4550
  out += "<br/>&nbsp;&nbsp;&nbsp; -> " + item + " = " + data;
4550
4551
  }
4551
4552
  }
4552
- return this.eventsDiv.append(out);
4553
+ this.eventsDiv.append(out);
4554
+ return this.changed = true;
4553
4555
  };
4554
4556
 
4555
4557
  return Log;
@@ -4746,13 +4748,25 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
4746
4748
  };
4747
4749
 
4748
4750
  function Resources() {
4749
- var _ref;
4751
+ var _ref, _ref1,
4752
+ _this = this;
4750
4753
  Resources.__super__.constructor.apply(this, arguments);
4751
4754
  _ref = [{}, {}, {}], this.resources = _ref[0], this.partials = _ref[1], this.servers = _ref[2];
4755
+ _ref1 = [false, false], this.resourcesChanged = _ref1[0], this.partialsChanged = _ref1[1];
4752
4756
  this.colors = {};
4753
4757
  this.bindColors();
4754
4758
  this.render();
4755
4759
  this.bindEvents();
4760
+ setInterval(function() {
4761
+ if (_this.resourcesChanged) {
4762
+ _this.resourcesChanged = false;
4763
+ _this.renderResources(_this.resources, _this.resourcesDiv);
4764
+ }
4765
+ if (_this.partialsChanged) {
4766
+ _this.partialsChanged = false;
4767
+ return _this.renderResources(_this.partials, _this.partialsDiv);
4768
+ }
4769
+ }, 200);
4756
4770
  }
4757
4771
 
4758
4772
  Resources.prototype.activate = function() {
@@ -4786,27 +4800,27 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
4786
4800
  var _this = this;
4787
4801
  Spine.bind('push_resource', function(resource) {
4788
4802
  _this.resources[resource.path] = resource;
4789
- return _this.renderResources(_this.resources, _this.resourcesDiv);
4803
+ return _this.resourcesChanged = true;
4790
4804
  });
4791
4805
  Spine.bind('destroy_resource', function(resource) {
4792
4806
  delete _this.resources[resource.path];
4793
- return _this.renderResources(_this.resources, _this.resourcesDiv);
4807
+ return _this.resourcesChanged = true;
4794
4808
  });
4795
4809
  Spine.bind('push_partial', function(partial) {
4796
4810
  _this.partials[partial.path] = partial;
4797
- return _this.renderResources(_this.partials, _this.partialsDiv);
4811
+ return _this.partialsChanged = true;
4798
4812
  });
4799
4813
  Spine.bind('destroy_partial', function(partial) {
4800
4814
  delete _this.partials[partial.path];
4801
- return _this.renderResources(_this.partials, _this.partialsDiv);
4815
+ return _this.partialsChanged = true;
4802
4816
  });
4803
4817
  Spine.bind('server_started', function(server) {
4804
4818
  _this.servers[server.id] = server;
4805
- return _this.renderResources(_this.resources, _this.resourcesDiv);
4819
+ return _this.resourcesChanged = true;
4806
4820
  });
4807
4821
  return Spine.bind('server_stopped', function(server) {
4808
4822
  delete _this.servers[server.id];
4809
- return _this.renderResources(_this.resources, _this.resourcesDiv);
4823
+ return _this.resourcesChanged = true;
4810
4824
  });
4811
4825
  };
4812
4826
 
@@ -5486,7 +5500,7 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
5486
5500
  (function() {
5487
5501
  (function() {
5488
5502
 
5489
- __out.push('<header class="jumbotron subhead">\n <h1>Resources</h1>\n <p class="lead">Overview of all Resources, the Partials and Content Types</p>\n</header>\n\n<section>\n\n<div class="row">\n \n <div class="span4">\n <div class="page-header"><h1>Resources</h1></div>\n <div id="resources">\n <div class="well dark-grey pagination-centered"><h2 class="white">0</h2></div>\n </div>\n </div>\n \n <div class="span4">\n <div class="page-header"><h1>Partials</h1></div>\n <div id="partials">\n <div class="well dark-grey pagination-centered"><h2 class="white">0</h2></div>\n </div>\n </div>\n \n <div class="span4">\n <div class="page-header"><h1>Content Types</h1></div>\n <div id="content_types"></div>\n </div>\n \n</div>\n\n</section>\n');
5503
+ __out.push('<header class="jumbotron subhead">\n <h1>Resources</h1>\n <p class="lead">Overview of all Resources, the Partials and Content Types</p>\n</header>\n\n<section>\n\n<div class="row">\n \n <div class="span4">\n <div class="page-header"><h1>Resources</h1></div>\n <div id="resources">\n <div class="well dark-grey pagination-centered"><h2 class="white">0</h2></div>\n </div>\n </div>\n \n <div class="span4">\n <div class="page-header"><h1>Partials</h1></div>\n <div id="partials">\n <div class="well dark-grey pagination-centered"><h2 class="white">0</h2></div>\n </div>\n </div>\n \n <div class="span4">\n <div class="page-header"><h1>Content Types</h1></div>\n <div id="content_types">\n <div class="well dark-grey pagination-centered"><h2 class="white">0</h2></div>\n </div>\n </div>\n \n</div>\n\n</section>\n');
5490
5504
 
5491
5505
  }).call(this);
5492
5506
 
@@ -1,5 +1,5 @@
1
1
  module Scales
2
2
  module Monitor
3
- VERSION = "0.0.1.beta.2"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ module Scales
6
6
 
7
7
  def on_open(env)
8
8
  send_initial_statuses(env)
9
- setup_subscription
9
+ setup_subscription!
10
10
  add_to_subscribers(env)
11
11
  end
12
12
 
@@ -15,7 +15,6 @@ module Scales
15
15
  end
16
16
 
17
17
  def on_message(env, msg)
18
- env.stream_send(msg)
19
18
  end
20
19
 
21
20
  def on_close(env)
@@ -34,7 +33,7 @@ module Scales
34
33
 
35
34
  private
36
35
 
37
- def setup_subscription
36
+ def setup_subscription!
38
37
  return if @subscribed
39
38
  @subscribers = []
40
39
 
@@ -43,6 +42,7 @@ module Scales
43
42
  events.on(:message) do |channel, message|
44
43
  @subscribers.each { |subscriber| subscriber.stream_send(message) }
45
44
  end
45
+
46
46
  @subscribed = true
47
47
  end
48
48
 
@@ -60,7 +60,6 @@ module Scales
60
60
  worker_statuses.each{ |worker| env.stream_send(worker) }
61
61
 
62
62
  request_queue.each{ |request| env.stream_send(request) }
63
- response_queue.each{ |request| env.stream_send(response) }
64
63
 
65
64
  push_resources.each{ |resource| env.stream_send(resource) }
66
65
  push_partials.each{ |partial| env.stream_send(partial) }
@@ -95,11 +94,11 @@ module Scales
95
94
  end
96
95
 
97
96
  def request_queue
98
- requests = Storage::Async.connection.llen("scales_request_queue")
97
+ requests = Storage::Async.connection.llen(Scales::Storage::REQUEST_QUEUE)
99
98
  return [] if requests == 0
100
99
 
101
100
  data = []
102
- Storage::Async.connection.lrange("scales_request_queue", 0, requests).each do |request|
101
+ Storage::Async.connection.lrange(Scales::Storage::REQUEST_QUEUE, 0, requests).each do |request|
103
102
  job = JSON.parse(request)
104
103
  data << {
105
104
  :id => job['scales.id'],
@@ -112,26 +111,6 @@ module Scales
112
111
  data
113
112
  end
114
113
 
115
- def response_queue
116
- responses = Storage::Async.connection.keys("scales_response_*")
117
- return [] if responses.empty?
118
-
119
- data = []
120
- responses.each do |response_key|
121
- response = Storage::Async.connection.lindex(response_key, 0)
122
- response = JSON.parse(response)
123
- data << {
124
- :id => response[1]['scales.id'],
125
- :worker_id => nil,
126
- :type => "worker_put_response_in_queue",
127
- :path => response[1]['PATH_INFO'],
128
- :method => response[1]['REQUEST_METHOD'],
129
- :status => response[0]
130
- }.to_json
131
- end
132
- data
133
- end
134
-
135
114
  def push_resources
136
115
  resources = Storage::Async.connection.keys("scales_resource_/*")
137
116
  return [] if resources.empty?
@@ -51,8 +51,8 @@ describe Scales::Monitor::WebSocket do
51
51
  it "sends requests" do
52
52
  with_api(described_class, {:verbose => true, :log_stdout => true}) do |server|
53
53
  json = "{\"scales.id\":\"4f57fcec795b6a6158796a1958e781f0\",\"SERVER_NAME\":\"0.0.0.0\",\"SERVER_PORT\":\"3005\",\"REQUEST_METHOD\":\"POST\",\"QUERY_STRING\":\"\",\"PATH_INFO\":\"/tracks\",\"HTTP_HOST\":\"0.0.0.0:3005\",\"HTTP_USER_AGENT\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.19 (KHTML, like Gecko) Version/6.0 Safari/536.19\",\"HTTP_ACCEPT\":\"text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8\",\"HTTP_ORIGIN\":\"http://0.0.0.0:3005\",\"HTTP_REFERER\":\"http://0.0.0.0:3005/tracks/new\",\"HTTP_ACCEPT_LANGUAGE\":\"en-us\",\"HTTP_ACCEPT_ENCODING\":\"gzip, deflate\",\"HTTP_CONNECTION\":\"keep-alive\",\"HTTP_VERSION\":\"1.1\",\"rack.version\":[1,0],\"rack.url_scheme\":null,\"rack.input\":\"utf8=%E2%9C%93&authenticity_token=gniWYAZpl67rSI0VYfrpoBXJ3Ipv9ZEv9VY9FSbyoDM%3D&track%5Bname%5D=Next+one&track%5Bartist%5D=Okay+here&commit=Create+Track\"}"
54
- Scales::Storage::Async.connection.lpush("scales_request_queue", json)
55
- Scales::Storage::Async.connection.lpush("scales_request_queue", json)
54
+ Scales::Storage::Async.connection.lpush(Scales::Storage::REQUEST_QUEUE, json)
55
+ Scales::Storage::Async.connection.lpush(Scales::Storage::REQUEST_QUEUE, json)
56
56
 
57
57
  requests = described_class.new.instance_eval{ request_queue }
58
58
  requests.should have_at_least(2).requests
@@ -60,18 +60,6 @@ describe Scales::Monitor::WebSocket do
60
60
  end
61
61
  end
62
62
 
63
- it "sends responds" do
64
- with_api(described_class, {:verbose => true, :log_stdout => true}) do |server|
65
- json = "[302,{\"Location\":\"http://0.0.0.0:3005/tracks/170\",\"Content-Type\":\"text/html; charset=utf-8\",\"Set-Cookie\":\"_app_session=BAh7B0kiCmZsYXNoBjoGRUZvOiVBY3Rpb25EaXNwYXRjaDo6Rmxhc2g6OkZsYXNoSGFzaAk6CkB1c2VkbzoIU2V0BjoKQGhhc2h7ADoMQGNsb3NlZEY6DUBmbGFzaGVzewY6C25vdGljZUkiJFRyYWNrIHdhcyBzdWNjZXNzZnVsbHkgY3JlYXRlZC4GOwBGOglAbm93MEkiD3Nlc3Npb25faWQGOwBGSSIlZDkxNDA4OTFmMWVhZTJlNGU2MmM3MmRkOTA4NDZjODUGOwBU--fd4912d39bd51eedcd5bf0519a939e5b38317b34; path=/; HttpOnly\",\"scales.id\":\"155a255dd3604fa2e39469e30aef3206\"},\"<html><body>You are being <a href=\\\"http://0.0.0.0:3005/tracks/170\\\">redirected</a>.</body></html>\"]"
66
- Scales::Storage::Async.connection.lpush("scales_response_155a255dd3604fa2e39469e30aef3206", json)
67
- Scales::Storage::Async.connection.lpush("scales_response_155a255dd3604fa2e39469e30aef3207", json)
68
-
69
- responses = described_class.new.instance_eval{ response_queue }
70
- responses.should have_at_least(2).responses
71
- EM.stop
72
- end
73
- end
74
-
75
63
  it "sends push resources" do
76
64
  with_api(described_class, {:verbose => true, :log_stdout => true}) do |server|
77
65
  Scales::Storage::Async.flushall!
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scales-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta.2
5
- prerelease: 6
4
+ version: 0.0.4
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Fankhauser
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-01 00:00:00.000000000 Z
12
+ date: 2012-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70329462937160 !ruby/object:Gem::Requirement
16
+ requirement: &70344757710880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70329462937160
24
+ version_requirements: *70344757710880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70329462935500 !ruby/object:Gem::Requirement
27
+ requirement: &70344757710380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,32 +32,32 @@ dependencies:
32
32
  version: '2.11'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70329462935500
35
+ version_requirements: *70344757710380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: scales-core
38
- requirement: &70329462956040 !ruby/object:Gem::Requirement
38
+ requirement: &70344757709940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
42
42
  - !ruby/object:Gem::Version
43
- version: 0.0.1.beta.2
43
+ version: 0.0.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70329462956040
46
+ version_requirements: *70344757709940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: scales-server
49
- requirement: &70329462954720 !ruby/object:Gem::Requirement
49
+ requirement: &70344757709460 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.1.beta.2
54
+ version: 0.0.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70329462954720
57
+ version_requirements: *70344757709460
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: goliath
60
- requirement: &70329462953120 !ruby/object:Gem::Requirement
60
+ requirement: &70344757709000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 1.0.0.beta.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70329462953120
68
+ version_requirements: *70344757709000
69
69
  description: Super Scale Caching Framework - Monitor Server
70
70
  email:
71
71
  - tommylefunk@googlemail.com
@@ -157,9 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
157
  required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  none: false
159
159
  requirements:
160
- - - ! '>'
160
+ - - ! '>='
161
161
  - !ruby/object:Gem::Version
162
- version: 1.3.1
162
+ version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
165
  rubygems_version: 1.8.11