reacter 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,22 +23,45 @@ class Reacter
23
23
  def connect(args={})
24
24
  @addr = @config.get(:address, '0.0.0.0')
25
25
  @port = @config.get(:port, 54546)
26
+ @buffer = []
27
+
28
+ if @config.get(:write)
29
+ writer_addr = @config.get!('write.address')
30
+ writer_port = @config.get!('write.port').to_i
31
+
32
+ @writer = TCPSocket.new(writer_addr, writer_port)
33
+ end
26
34
  end
27
35
 
28
36
  def send(message, format=nil)
29
- # TODO: implement this for relay support
30
- # support: host
31
- # port
32
- # format
33
- # timeout
34
- #
37
+ if defined?(@writer)
38
+ if (sz = @config.get(:buffersize))
39
+ if @buffer.length == sz
40
+ payload = @buffer.join("\n")
41
+ @buffer = []
42
+ else
43
+ @buffer << Message.dump(message, format)
44
+ end
45
+ else
46
+ payload = Message.dump(message, format)
47
+ end
48
+
49
+ @writer.puts(payload)
50
+ @writer.flush()
51
+
52
+ return true
53
+ else
54
+ return false
55
+ end
35
56
  end
36
57
 
37
58
  def poll(&block)
38
- @server = EM.start_server(@addr, @port, SocketHandler, proc{|data|
39
- messages = Message.parse(data.chomp)
40
- block.call(messages) unless messages.empty?
41
- })
59
+ if @addr and @port
60
+ @server = EM.start_server(@addr, @port, SocketHandler, proc{|data|
61
+ messages = Message.parse(data.chomp)
62
+ block.call(messages) unless messages.empty?
63
+ })
64
+ end
42
65
  end
43
66
 
44
67
  def disconnect()
@@ -19,6 +19,7 @@ class Reacter
19
19
  adapter = Adapter.create(c['type'], c)
20
20
  adapter.connect()
21
21
  @_adapters << adapter
22
+ Util.info("Relaying messages via #{c['type']} adapter")
22
23
  end
23
24
  end
24
25
 
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.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &6262340 !ruby/object:Gem::Requirement
16
+ requirement: &21855120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6262340
24
+ version_requirements: *21855120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-http-server
27
- requirement: &5529980 !ruby/object:Gem::Requirement
27
+ requirement: &21965600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *5529980
35
+ version_requirements: *21965600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: deep_merge
38
- requirement: &5529280 !ruby/object:Gem::Requirement
38
+ requirement: &21965080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *5529280
46
+ version_requirements: *21965080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hashlib
49
- requirement: &5528400 !ruby/object:Gem::Requirement
49
+ requirement: &21964560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *5528400
57
+ version_requirements: *21964560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hiredis
60
- requirement: &5527380 !ruby/object:Gem::Requirement
60
+ requirement: &21963960 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *5527380
68
+ version_requirements: *21963960
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: multi_json
71
- requirement: &5526640 !ruby/object:Gem::Requirement
71
+ requirement: &21963120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *5526640
79
+ version_requirements: *21963120
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: oj
82
- requirement: &5525740 !ruby/object:Gem::Requirement
82
+ requirement: &21962540 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *5525740
90
+ version_requirements: *21962540
91
91
  description: A utility for consuming, transforming, and routing monitoring data from
92
92
  various sources
93
93
  email: ghetzel@outbrain.com