recognizer 0.3.0-java → 0.4.0-java
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/README.org +3 -7
- data/lib/recognizer.rb +6 -10
- data/lib/recognizer/input.rb +26 -0
- data/lib/recognizer/inputs/amqp.rb +4 -4
- data/lib/recognizer/inputs/tcp.rb +2 -4
- data/lib/recognizer/librato.rb +2 -2
- data/lib/recognizer/version.rb +1 -1
- data/recognizer.gemspec +1 -1
- metadata +13 -20
data/README.org
CHANGED
@@ -7,10 +7,8 @@
|
|
7
7
|
|
8
8
|
[[https://github.com/portertech/recognizer/raw/master/recognizer.gif]]
|
9
9
|
* Install
|
10
|
-
Executable Java JAR
|
11
|
-
: wget
|
12
|
-
RubyGems
|
13
|
-
: gem install recognizer
|
10
|
+
Executable Java JAR
|
11
|
+
: wget http://portertech.s3.amazonaws.com/recognizer/recognizer.jar
|
14
12
|
* Configure
|
15
13
|
Example: =config.json=
|
16
14
|
: {
|
@@ -28,9 +26,7 @@
|
|
28
26
|
* Usage
|
29
27
|
Executable Java JAR
|
30
28
|
: java -jar recognizer.jar -h
|
31
|
-
|
32
|
-
: recognizer -h
|
33
|
-
|
29
|
+
:
|
34
30
|
: Usage: recognizer (options)
|
35
31
|
: -c, --config CONFIG The config file path
|
36
32
|
: -h, --help Show this message
|
data/lib/recognizer.rb
CHANGED
@@ -2,6 +2,7 @@ require "logger"
|
|
2
2
|
require "recognizer/cli"
|
3
3
|
require "recognizer/config"
|
4
4
|
require "recognizer/librato"
|
5
|
+
require "recognizer/input"
|
5
6
|
require "recognizer/inputs/tcp"
|
6
7
|
require "recognizer/inputs/amqp"
|
7
8
|
|
@@ -24,20 +25,15 @@ module Recognizer
|
|
24
25
|
)
|
25
26
|
librato.run
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
:options => options,
|
30
|
-
:input_queue => input_queue
|
31
|
-
)
|
32
|
-
tcp.run
|
33
|
-
|
34
|
-
if options.has_key?(:amqp)
|
35
|
-
amqp = Recognizer::Input::AMQP.new(
|
28
|
+
Recognizer::Input::Base.descendants.each do |klass|
|
29
|
+
input = klass.new(
|
36
30
|
:logger => logger,
|
37
31
|
:options => options,
|
38
32
|
:input_queue => input_queue
|
39
33
|
)
|
40
|
-
|
34
|
+
if input.enabled?
|
35
|
+
input.run
|
36
|
+
end
|
41
37
|
end
|
42
38
|
|
43
39
|
loop do
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Recognizer
|
2
|
+
module Input
|
3
|
+
class Base
|
4
|
+
def initialize(options={})
|
5
|
+
@enabled = true
|
6
|
+
@logger = options[:logger]
|
7
|
+
@options = options[:options]
|
8
|
+
@input_queue = options[:input_queue]
|
9
|
+
end
|
10
|
+
|
11
|
+
def enabled?
|
12
|
+
!!@enabled
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.descendants
|
20
|
+
ObjectSpace.each_object(Class).select do |klass|
|
21
|
+
klass < self
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,11 +2,11 @@ require "hot_bunnies"
|
|
2
2
|
|
3
3
|
module Recognizer
|
4
4
|
module Input
|
5
|
-
class AMQP
|
5
|
+
class AMQP < Base
|
6
6
|
def initialize(options={})
|
7
|
-
|
8
|
-
|
9
|
-
@
|
7
|
+
super
|
8
|
+
|
9
|
+
@enabled = @options.has_key?(:amqp)
|
10
10
|
|
11
11
|
@options[:amqp][:exchange] ||= Hash.new
|
12
12
|
@options[:amqp][:exchange][:name] ||= "graphite"
|
@@ -3,11 +3,9 @@ require "socket"
|
|
3
3
|
|
4
4
|
module Recognizer
|
5
5
|
module Input
|
6
|
-
class TCP
|
6
|
+
class TCP < Base
|
7
7
|
def initialize(options={})
|
8
|
-
|
9
|
-
@options = options[:options]
|
10
|
-
@input_queue = options[:input_queue]
|
8
|
+
super
|
11
9
|
|
12
10
|
@options[:tcp] ||= Hash.new
|
13
11
|
@tcp_connections = Queue.new
|
data/lib/recognizer/librato.rb
CHANGED
@@ -42,8 +42,8 @@ module Recognizer
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def extract_metric_source(metric_path)
|
46
|
-
metric_source
|
45
|
+
def extract_metric_source(metric_path, metric_source=nil)
|
46
|
+
metric_source ||= @options[:librato][:metric_source]
|
47
47
|
fallback_source = "recognizer"
|
48
48
|
case metric_source
|
49
49
|
when String
|
data/lib/recognizer/version.rb
CHANGED
data/recognizer.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recognizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -83,13 +83,13 @@ dependencies:
|
|
83
83
|
requirements:
|
84
84
|
- - '='
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.
|
86
|
+
version: 1.0.3
|
87
87
|
none: false
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - '='
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 0.
|
92
|
+
version: 1.0.3
|
93
93
|
none: false
|
94
94
|
prerelease: false
|
95
95
|
type: :runtime
|
@@ -101,22 +101,15 @@ executables:
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
-
|
105
|
-
|
106
|
-
-
|
107
|
-
|
108
|
-
-
|
109
|
-
|
110
|
-
-
|
111
|
-
|
112
|
-
-
|
113
|
-
bGliL3JlY29nbml6ZXIvY29uZmlnLnJi
|
114
|
-
- !binary |-
|
115
|
-
bGliL3JlY29nbml6ZXIvbGlicmF0by5yYg==
|
116
|
-
- !binary |-
|
117
|
-
bGliL3JlY29nbml6ZXIvaW5wdXRzL2FtcXAucmI=
|
118
|
-
- !binary |-
|
119
|
-
bGliL3JlY29nbml6ZXIvaW5wdXRzL3RjcC5yYg==
|
104
|
+
- bin/recognizer
|
105
|
+
- lib/recognizer.rb
|
106
|
+
- lib/recognizer/version.rb
|
107
|
+
- lib/recognizer/cli.rb
|
108
|
+
- lib/recognizer/input.rb
|
109
|
+
- lib/recognizer/config.rb
|
110
|
+
- lib/recognizer/librato.rb
|
111
|
+
- lib/recognizer/inputs/amqp.rb
|
112
|
+
- lib/recognizer/inputs/tcp.rb
|
120
113
|
- recognizer.gemspec
|
121
114
|
- README.org
|
122
115
|
- MIT-LICENSE.txt
|