reacter 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 705e53e181d608617873b15bfd3cf551c63f6b0f
4
- data.tar.gz: b294a6dadfdc57f23a12e3e9c7eb88c7ff1bbcbf
3
+ metadata.gz: 698f0acf6a91c8a8f222c2b5a9c794a9649b1b9f
4
+ data.tar.gz: df4407d0644729a0f432e9dba966caa10fc30a27
5
5
  SHA512:
6
- metadata.gz: 8a4f7b6cb348e915b831e14e8655ae42614b6af505357ab1d6eda503815183ffc75c178d9ebed2a1dffe1814ebfade07cac6c1c801ee482f20d546d9c417e957
7
- data.tar.gz: c398d6e3c7bcbd9e7512c2ad2fcbe1768450bf5674bf356a222962042d8de5926c16126c1de90654c7c535875d9947a653a2c983fbe4202ff08b221c48729b70
6
+ metadata.gz: 9db488df26691082e2ef23d48675359075856e68a0936a803175ddf177508ea2f53fb4046eb49f35468733f45bb8ce412c7fdb864b0d116a8ea57152bd85deb8
7
+ data.tar.gz: f7478402230db72f05b0d8cfd91585a13aeb832d1c795e33669f0d4b7b40b23c842107cd8cd91ba02cd953f7e4385b2809fd246b10d931ed7f28bb9a51bb764d
@@ -6,12 +6,14 @@ require 'reacter/message'
6
6
  require 'reacter/config'
7
7
  require 'reacter/util'
8
8
 
9
- class AdapterConnectionFailed < Exception; end
10
- class AdapterConnectionFaulted < Exception; end
11
- class AdapterConnectionClosed < Exception; end
12
- class AdapterExit < Exception; end
13
9
 
14
10
  class Reacter
11
+ class AdapterConnectionFailed < Exception; end
12
+ class AdapterConnectionFaulted < Exception; end
13
+ class AdapterConnectionClosed < Exception; end
14
+ class AdapterExit < Exception; end
15
+
16
+
15
17
  class Adapter
16
18
  attr :config
17
19
  attr :type
@@ -42,7 +44,7 @@ class Reacter
42
44
 
43
45
  # implement: manual disconnect / cleanup
44
46
  def disconnect()
45
- raise AdapterExit
47
+ @_connected = false
46
48
  end
47
49
 
48
50
  def disable()
@@ -10,14 +10,21 @@ class Reacter
10
10
  require 'amqp'
11
11
 
12
12
  DEFAULT_QUEUENAME='reacter'
13
+ DEFAULT_TIMEOUT=3
13
14
 
14
15
  def connect(args={})
16
+ @_errback = proc do
17
+ raise AdapterConnectionFailed
18
+ end
19
+
15
20
  @_connection = AMQP.connect({
16
21
  :host => @config.get(:hostname, 'localhost'),
17
22
  :port => @config.get(:port, 5672),
18
23
  :username => @config.get(:username, 'guest'),
19
24
  :password => @config.get(:password, 'guest'),
20
- :vhost => @config.get(:vhost, '/')
25
+ :vhost => @config.get(:vhost, '/'),
26
+ :timeout => @config.get(:timeout, DEFAULT_TIMEOUT),
27
+ :on_tcp_connection_failure => @_errback
21
28
  })
22
29
 
23
30
  @_channel = AMQP::Channel.new(@_connection)
data/lib/reacter/core.rb CHANGED
@@ -36,7 +36,6 @@ class Reacter
36
36
  @_adapters << instance
37
37
  else
38
38
  raise "Adapter '#{type}' not found, exiting"
39
- exit 1
40
39
  end
41
40
  end
42
41
  else
@@ -80,21 +79,8 @@ class Reacter
80
79
  next unless adapter.enabled?
81
80
 
82
81
  poller = proc do
83
- begin
84
- adapter.poll do |messages|
85
- dispatch.call(messages)
86
- end
87
- rescue AdapterConnectionFailed => e
88
- Util.error("Adapter connection failed: #{e.message}")
89
-
90
- rescue AdapterConnectionFaulted => e
91
- Util.error("Adapter connection error: #{e.message}")
92
-
93
- rescue AdapterConnectionClosed => e
94
- Util.info("Adapter closed connection")
95
-
96
- rescue AdapterExit => e
97
- adapter.disable()
82
+ adapter.poll do |messages|
83
+ dispatch.call(messages)
98
84
  end
99
85
  end
100
86
 
@@ -0,0 +1,23 @@
1
+ class Reacter
2
+ class Message
3
+ class Parser
4
+ class<<self
5
+ # implement: determine whether the raw message is in a format this parser
6
+ # can normalize
7
+ def detected?(message)
8
+ false
9
+ end
10
+
11
+ # implement: parse the raw input message, returning an array of Messages
12
+ def parse(message)
13
+ nil
14
+ end
15
+
16
+ # take a Message and return the orginal format
17
+ def dump(message)
18
+ nil
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,8 +1,8 @@
1
- require 'reacter/parsers/default'
1
+ require 'reacter/parser'
2
2
 
3
3
  class Reacter
4
4
  class Message
5
- class CollectdParser < DefaultParser
5
+ class CollectdParser < Parser
6
6
  class<<self
7
7
  def detected?(message)
8
8
  (message[0..6] == 'PUTVAL ')
@@ -1,8 +1,8 @@
1
- require 'reacter/parsers/default'
1
+ require 'reacter/parser'
2
2
 
3
3
  class Reacter
4
4
  class Message
5
- class GraphiteParser < DefaultParser
5
+ class GraphiteParser < Parser
6
6
  class<<self
7
7
  # Graphite
8
8
  # |metric-----|value|epoch----|
@@ -1,8 +1,8 @@
1
- require 'reacter/parsers/default'
1
+ require 'reacter/parser'
2
2
 
3
3
  class Reacter
4
4
  class Message
5
- class JsonParser < DefaultParser
5
+ class JsonParser < Parser
6
6
  class<<self
7
7
  require 'json'
8
8
 
@@ -1,8 +1,8 @@
1
- require 'reacter/parsers/default'
1
+ require 'reacter/parser'
2
2
 
3
3
  class Reacter
4
4
  class Message
5
- class TsdbParser < DefaultParser
5
+ class TsdbParser < Parser
6
6
  class<<self
7
7
  def detected?(message)
8
8
  return (message.upcase[0..4] == 'PUT ')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reacter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Hetzel
@@ -71,8 +71,8 @@ files:
71
71
  - lib/reacter/config.rb
72
72
  - lib/reacter/core.rb
73
73
  - lib/reacter/message.rb
74
+ - lib/reacter/parser.rb
74
75
  - lib/reacter/parsers/collectd.rb
75
- - lib/reacter/parsers/default.rb
76
76
  - lib/reacter/parsers/graphite.rb
77
77
  - lib/reacter/parsers/json.rb
78
78
  - lib/reacter/parsers/tsdb.rb
@@ -1,19 +0,0 @@
1
- class Reacter
2
- class Message
3
- class DefaultParser
4
- class<<self
5
- def detected?(message)
6
- false
7
- end
8
-
9
- def parse(message)
10
- nil
11
- end
12
-
13
- def dump(message)
14
- nil
15
- end
16
- end
17
- end
18
- end
19
- end