ustate-client 0.0.1

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.
@@ -0,0 +1,66 @@
1
+ module UState
2
+ class Server
3
+ # A server binds together Backends, an Index, and Sinks.
4
+ # - Backends spawn Connections with EM.
5
+ # - Connections receive messages from clients, and pass States to the Index.
6
+ # - The Index aggregates states together and informs Sinks.
7
+
8
+ class Error < RuntimeError; end
9
+
10
+ require 'eventmachine'
11
+ require 'ustate/server/connection'
12
+ require 'ustate/server/index'
13
+ require 'ustate/server/backends'
14
+ require 'treetop'
15
+ require 'ustate/query_string.rb'
16
+
17
+ attr_accessor :backends
18
+ attr_accessor :index
19
+
20
+ def initialize(opts = {})
21
+ # Backends
22
+ @backends = []
23
+ b = Backends::TCP.new opts
24
+ b.server = self
25
+ @backends << b
26
+
27
+ @index = Index.new
28
+
29
+ setup_signals
30
+ end
31
+
32
+ def start
33
+ @index.start
34
+
35
+ # Right now b.start blocks... should look into EM
36
+ @backends.map do |b|
37
+ b.start
38
+ end
39
+ end
40
+
41
+ def stop
42
+ @backends.map do |b|
43
+ if b.running?
44
+ b.stop
45
+ else
46
+ stop!
47
+ end
48
+ end
49
+
50
+ @index.stop
51
+ end
52
+
53
+ def stop!
54
+ @backends.map do |b|
55
+ b.stop!
56
+ end
57
+
58
+ @index.stop!
59
+ end
60
+
61
+ def setup_signals
62
+ trap('INT') { stop! }
63
+ trap('TERM') { stop }
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,18 @@
1
+ class UState::State
2
+ include Beefcake::Message
3
+
4
+ optional :time, :int64, 1
5
+ optional :state, :string, 2
6
+ optional :service, :string, 3
7
+ optional :host, :string, 4
8
+ optional :description, :string, 5
9
+ optional :metric_f, :float, 15
10
+
11
+ def metric
12
+ @metric || metric_f
13
+ end
14
+
15
+ def metric=(m)
16
+ @metric = m
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module UState
2
+ VERSION = '0.0.1'
3
+ end
data/lib/ustate.rb ADDED
@@ -0,0 +1,9 @@
1
+ module UState
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
3
+
4
+ require 'beefcake'
5
+ require 'ustate/version'
6
+ require 'ustate/state'
7
+ require 'ustate/query'
8
+ require 'ustate/message'
9
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ustate-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kyle Kingsbury
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-05 00:00:00.000000000Z
13
+ dependencies: []
14
+ description:
15
+ email: aphyr@aphyr.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/ustate.rb
21
+ - lib/ustate/query_string.treetop
22
+ - lib/ustate/message.rb
23
+ - lib/ustate/version.rb
24
+ - lib/ustate/server/graphite.rb
25
+ - lib/ustate/server/backends.rb
26
+ - lib/ustate/server/backends/base.rb
27
+ - lib/ustate/server/backends/tcp.rb
28
+ - lib/ustate/server/index.rb
29
+ - lib/ustate/server/connection.rb
30
+ - lib/ustate/server.rb
31
+ - lib/ustate/dash.rb
32
+ - lib/ustate/state.rb
33
+ - lib/ustate/query.rb
34
+ - lib/ustate/client/query.rb
35
+ - lib/ustate/client.rb
36
+ - lib/ustate/dash/views/index.erubis
37
+ - lib/ustate/dash/views/layout.erubis
38
+ - lib/ustate/dash/views/css.scss
39
+ - lib/ustate/dash/state.rb
40
+ - lib/ustate/dash/controller/index.rb
41
+ - lib/ustate/dash/controller/css.rb
42
+ - lib/ustate/dash/config.rb
43
+ - lib/ustate/dash/helper/renderer.rb
44
+ - lib/ustate/query_string.rb
45
+ - LICENSE
46
+ - README.markdown
47
+ homepage: https://github.com/aphyr/ustate
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: 1.8.7
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project: ustate-client
67
+ rubygems_version: 1.8.10
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Client for the distributed state server ustate.
71
+ test_files: []