ffwd-statsd 0.1.7 → 0.2.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d3b4a2e4bcc5b14ee961b01cf6c0dc3c5e70e6f9
4
+ data.tar.gz: 69c7889991e1805b59406940512b4aec82137bea
5
+ SHA512:
6
+ metadata.gz: 3b4795f0c30ef9bb1550251651eba363fc414e319ec47f23e95d0d19145078ebd9f1efe57765bb0fd4d72e758fe11b97b190459114ec90ac8ad23c0a2fab6043
7
+ data.tar.gz: 5c09548c46acd68ef354d8e6eb220f1fe0b1e1d86761fa00f9cfd508b1fbb7055f716beafcbcc81403655987224cd69db9351dfc772335ad34e6550fcd02114d
@@ -13,63 +13,30 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require 'ffwd/logging'
17
16
  require 'ffwd/connection'
18
17
 
19
18
  require_relative 'parser'
20
19
 
21
20
  module FFWD::Plugin::Statsd
22
- module Connection
23
- module ConnectionBase
24
- def receive_statsd_frame(data)
25
- metric = Parser.parse(data)
26
- return if metric.nil?
27
- @core.input.metric metric
28
- @bind.increment :received_metrics
29
- rescue ParserError => e
30
- log.error "Invalid frame '#{data}': #{e}"
31
- @bind.increment :failed_metrics
32
- rescue => e
33
- log.error "Error when parsing metric '#{data}'", e
34
- @bind.increment :failed_metrics
35
- end
21
+ class Connection < FFWD::Connection
22
+ def initialize bind, core, config
23
+ @bind = bind
24
+ @core = core
36
25
  end
37
26
 
38
- class UDP < FFWD::Connection
39
- include ConnectionBase
40
- include FFWD::Logging
41
-
42
- def initialize bind, core
43
- @bind = bind
44
- @core = core
45
- end
46
-
47
- def self.plugin_type
48
- "statsd_udp_in"
49
- end
50
-
51
- def receive_data data
52
- receive_statsd_frame data
53
- end
54
- end
55
-
56
- class TCP < FFWD::Connection
57
- include ConnectionBase
58
- include FFWD::Logging
59
- include EM::Protocols::LineText2
60
-
61
- def initialize bind, core
62
- @bind = bind
63
- @core = core
64
- end
65
-
66
- def self.plugin_type
67
- "statsd_tcp_in"
68
- end
69
-
70
- def receive_line(data)
71
- receive_statsd_frame data
72
- end
27
+ protected
28
+
29
+ def receive_statsd_frame(data)
30
+ metric = Parser.parse(data)
31
+ return if metric.nil?
32
+ @core.input.metric metric
33
+ @bind.increment :received_metrics
34
+ rescue ParserError => e
35
+ log.error "Invalid frame '#{data}': #{e}"
36
+ @bind.increment :failed_metrics
37
+ rescue => e
38
+ log.error "Error when parsing metric '#{data}'", e
39
+ @bind.increment :failed_metrics
73
40
  end
74
41
  end
75
42
  end
@@ -16,7 +16,7 @@
16
16
  module FFWD
17
17
  module Plugin
18
18
  module Statsd
19
- VERSION = "0.1.7"
19
+ VERSION = "0.2.0"
20
20
  end
21
21
  end
22
22
  end
@@ -27,29 +27,43 @@ module FFWD::Plugin::Statsd
27
27
 
28
28
  DEFAULT_HOST = "localhost"
29
29
  DEFAULT_PORT = 8125
30
+ DEFAULT_PROTOCOL = "udp"
30
31
 
31
- INPUTS = {:tcp => Connection::TCP, :udp => Connection::UDP}
32
+ class InputUDP < FFWD::Plugin::Statsd::Connection
33
+ def self.plugin_type
34
+ "statsd_udp_in"
35
+ end
32
36
 
33
- def self.setup_input opts, core
34
- opts[:host] ||= DEFAULT_HOST
35
- opts[:port] ||= DEFAULT_PORT
36
- protocol = FFWD.parse_protocol(opts[:protocol] || "udp")
37
+ def receive_data data
38
+ receive_statsd_frame data
39
+ end
40
+ end
37
41
 
38
- unless connection = INPUTS[protocol.family]
39
- raise "No connection for protocol family: #{protocol.family}"
42
+ class InputTCP < FFWD::Plugin::Statsd::Connection
43
+ include EM::Protocols::LineText2
44
+
45
+ def self.plugin_type
46
+ "statsd_tcp_in"
40
47
  end
41
48
 
42
- protocol.bind opts, core, log, connection
49
+ def receive_line(data)
50
+ receive_statsd_frame data
51
+ end
43
52
  end
44
53
 
45
- def self.setup_tunnel opts, core, tunnel
46
- opts[:port] ||= DEFAULT_PORT
47
- protocol = FFWD.parse_protocol(opts[:protocol] || "tcp")
54
+ INPUTS = {:tcp => InputTCP, :udp => InputUDP}
55
+
56
+ def self.setup_input config
57
+ config[:host] ||= DEFAULT_HOST
58
+ config[:port] ||= DEFAULT_PORT
59
+ config[:protocol] ||= DEFAULT_PROTOCOL
60
+
61
+ protocol = FFWD.parse_protocol config[:protocol]
48
62
 
49
63
  unless connection = INPUTS[protocol.family]
50
64
  raise "No connection for protocol family: #{protocol.family}"
51
65
  end
52
66
 
53
- protocol.tunnel opts, core, tunnel, log, connection
67
+ protocol.bind config, log, connection
54
68
  end
55
69
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffwd-statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - John-John Tedro
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ffwd
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
21
- version: 0.1.7
19
+ version: 0.2.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
29
- version: 0.1.7
26
+ version: 0.2.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-mocks
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description:
@@ -67,32 +60,31 @@ extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
62
  - lib/ffwd/plugin/statsd.rb
70
- - lib/ffwd/plugin/statsd/version.rb
71
63
  - lib/ffwd/plugin/statsd/parser.rb
72
64
  - lib/ffwd/plugin/statsd/connection.rb
65
+ - lib/ffwd/plugin/statsd/version.rb
73
66
  homepage: https://github.com/spotify/ffwd
74
67
  licenses:
75
68
  - Apache 2.0
69
+ metadata: {}
76
70
  post_install_message:
77
71
  rdoc_options: []
78
72
  require_paths:
79
73
  - lib
80
74
  required_ruby_version: !ruby/object:Gem::Requirement
81
- none: false
82
75
  requirements:
83
- - - ! '>='
76
+ - - '>='
84
77
  - !ruby/object:Gem::Version
85
78
  version: '0'
86
79
  required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
80
  requirements:
89
- - - ! '>='
81
+ - - '>='
90
82
  - !ruby/object:Gem::Version
91
83
  version: '0'
92
84
  requirements: []
93
85
  rubyforge_project:
94
- rubygems_version: 1.8.23
86
+ rubygems_version: 2.0.3
95
87
  signing_key:
96
- specification_version: 3
88
+ specification_version: 4
97
89
  summary: StatsD support for FFWD.
98
90
  test_files: []