ffwd 0.1.1 → 0.1.2

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: 662d6ca5d2a1a07cf582c04a365f705c1cc807f9
4
+ data.tar.gz: 1a823ac6b62d55c1b2751830a6ffcdbb13c92fd9
5
+ SHA512:
6
+ metadata.gz: 1e8b9bf081c3883429a20a0be30c3f0b22203057061f45fe828f0a3b23ec8b193e58814915fcdc1e05193a1048a8fc1065adb44c2909ee64ac68575a0756fcf7
7
+ data.tar.gz: 602b3ea6457cab25305334696046d1b21364a70327e91767df9fd3b321f52462d9f6d642604c22540ee3484a2e16aa61669cea3385b0f9be577cc8e6352c9c62
data/lib/ffwd.rb CHANGED
@@ -145,15 +145,40 @@ module FFWD
145
145
 
146
146
  def self.dump_loaded_plugins
147
147
  FFWD::Plugin.loaded.each do |name, plugin|
148
- puts " Plugin '#{name}'"
148
+ unless description = plugin.description
149
+ description = "no description"
150
+ end
151
+
152
+ puts " Plugin '#{name}' (#{description})"
149
153
  puts " Source: #{plugin.source}"
150
- puts " Supports: #{plugin.capabilities.join(' ')}"
151
- puts " Description: #{plugin.description}" if plugin.description
154
+ puts " Supported modes: #{plugin.capabilities.join(', ')}"
155
+
152
156
  unless plugin.options.empty?
153
157
  puts " Available Options:"
154
158
  plugin.options.each do |opt|
155
- puts " :#{opt[:name]} (default: #{opt[:default].inspect})"
156
- puts " #{opt[:help]}" if opt[:help]
159
+ if modes = opt[:modes]
160
+ modes = modes.join(', ')
161
+ else
162
+ modes = "all modes"
163
+ end
164
+
165
+ puts " :#{opt[:name]} (#{modes})"
166
+
167
+ unless (default = opt[:default]).nil?
168
+ puts " Default: #{default.inspect}"
169
+ else
170
+ puts " Default: (no default)"
171
+ end
172
+
173
+ if help = opt[:help]
174
+ if help.is_a? Array
175
+ help.each do |h|
176
+ puts " #{h}"
177
+ end
178
+ else
179
+ puts " #{help}"
180
+ end
181
+ end
157
182
  end
158
183
  end
159
184
  end
data/lib/ffwd/plugin.rb CHANGED
@@ -92,17 +92,17 @@ module FFWD
92
92
 
93
93
  module ClassMethods
94
94
  def register_plugin(name, opts={})
95
- options = {
95
+ config = {
96
96
  :mod => self,
97
97
  :description => opts[:description],
98
98
  :options => opts[:options] || []
99
99
  }
100
100
 
101
- options[:setup_input_method_name] = (opts[:setup_input_method] || :setup_input)
102
- options[:setup_output_method_name] = (opts[:setup_output_method] || :setup_output)
103
- options[:setup_tunnel_method_name] = (opts[:setup_tunnel_method] || :setup_tunnel)
101
+ config[:setup_input_method_name] = (opts[:setup_input_method] || :setup_input)
102
+ config[:setup_output_method_name] = (opts[:setup_output_method] || :setup_output)
103
+ config[:setup_tunnel_method_name] = (opts[:setup_tunnel_method] || :setup_tunnel)
104
104
 
105
- FFWD::Plugin.discovered[name] = options
105
+ FFWD::Plugin.discovered[name] = config
106
106
  end
107
107
  end
108
108
 
@@ -115,8 +115,8 @@ module FFWD
115
115
  end
116
116
 
117
117
  def self.load_discovered source
118
- FFWD::Plugin.discovered.each do |name, options|
119
- FFWD::Plugin.loaded[name] = Loaded.new source, name, options
118
+ FFWD::Plugin.discovered.each do |name, config|
119
+ FFWD::Plugin.loaded[name] = Loaded.new source, name, config
120
120
  end
121
121
 
122
122
  FFWD::Plugin.discovered.clear
@@ -152,7 +152,8 @@ module FFWD
152
152
  end
153
153
 
154
154
  def self.option name, opts={}
155
- {:name => name, :default => opts[:default], :help => opts[:help]}
155
+ {:name => name, :default => opts[:default], :help => opts[:help],
156
+ :modes => opts[:modes]}
156
157
  end
157
158
  end
158
159
  end
@@ -28,16 +28,26 @@ module FFWD::Plugin::JSON
28
28
  DEFAULT_HOST = "localhost"
29
29
  DEFAULT_PORT = 19000
30
30
  DEFAULT_PROTOCOL = "tcp"
31
+ DEFAULT_KIND = "line"
31
32
 
32
33
  register_plugin "json",
33
34
  :description => "A simple JSON protocol implementation",
34
35
  :options => [
35
36
  FFWD::Plugin.option(
36
- :kind, :default => :line,
37
- :help => "Kind of protocol to use, valid options are: :frame and :line."),
37
+ :kind, :default => DEFAULT_KIND,
38
+ :help => [
39
+ "Kind of protocol to use, valid options are 'frame' and 'line'.",
40
+ "'frame' means that the protocol is frame delimited, " +
41
+ "so each received datagram is received.",
42
+ "'line' means that the protocol is line-delimited, " +
43
+ "each line is assumed to be a JSON object."
44
+ ]),
38
45
  FFWD::Plugin.option(
39
46
  :protocol, :default => DEFAULT_PROTOCOL,
40
- :help => "Protocol to use when receiving messages. When :kind is :frame, this should be 'udp'.")
47
+ :help => [
48
+ "Protocol to use when receiving messages.",
49
+ "When :kind is 'frame', this should be 'udp'."
50
+ ])
41
51
  ]
42
52
 
43
53
  class LineConnection < FFWD::Connection
@@ -67,31 +77,22 @@ module FFWD::Plugin::JSON
67
77
  end
68
78
  end
69
79
 
70
- KINDS = {
71
- :frame => FrameConnection,
72
- :line => LineConnection,
73
- }
80
+ KINDS = {"frame" => FrameConnection, "line" => LineConnection}
74
81
 
75
82
  def self.setup_input opts, core
83
+ protocol = FFWD.parse_protocol opts[:protocol] || DEFAULT_PROTOCOL
84
+ kind = (opts[:kind] || DEFAULT_KIND).to_s
85
+ raise "No such kind: #{kind}" unless connection = KINDS[kind]
76
86
  opts[:host] ||= DEFAULT_HOST
77
87
  opts[:port] ||= DEFAULT_PORT
78
- protocol = FFWD.parse_protocol(opts[:protocol] || DEFAULT_PROTOCOL)
79
- kind = opts[:kind] || :line
80
- unless connection = KINDS[kind]
81
- raise "No such kind: #{kind}"
82
- end
83
-
84
88
  protocol.bind opts, core, log, connection
85
89
  end
86
90
 
87
91
  def self.setup_tunnel opts, core, tunnel
92
+ protocol = FFWD.parse_protocol opts[:protocol] || "tcp"
93
+ kind = (opts[:kind] || DEFAULT_KIND).to_s
94
+ raise "No such kind: #{kind}" unless connection = KINDS[kind]
88
95
  opts[:port] ||= DEFAULT_PORT
89
- protocol = FFWD.parse_protocol(opts[:protocol] || "tcp")
90
- kind = opts[:kind] || :line
91
- unless connection = KINDS[kind]
92
- raise "No such kind: #{kind}"
93
- end
94
-
95
96
  protocol.tunnel opts, core, tunnel, log, connection
96
97
  end
97
98
  end
@@ -28,13 +28,13 @@ module FFWD::Plugin
28
28
  register_plugin "log",
29
29
  :description => "A simple plugin that outputs to the primary log.",
30
30
  :options => [
31
- FFWD::Plugin.option(:prefix, :help => "Prefix for every line logged."),
31
+ FFWD::Plugin.option(:prefix, :help => [
32
+ "Prefix for every line logged."
33
+ ]),
32
34
  ]
33
35
 
34
-
35
36
  def self.setup_output opts, core
36
- prefix = opts[:prefix]
37
- Writer.new core, prefix
37
+ Writer.new core, opts[:prefix]
38
38
  end
39
39
  end
40
40
  end
@@ -22,6 +22,7 @@ module FFWD::Statistics
22
22
  include FFWD::Lifecycle
23
23
 
24
24
  DEFAULT_PERIOD = 10
25
+ DEFAULT_PREFIX = "ffwd"
25
26
 
26
27
  # Initialize the statistics collector.
27
28
  #
@@ -38,6 +39,7 @@ module FFWD::Statistics
38
39
  @reporters = {}
39
40
  @channel = channel
40
41
  @timer = nil
42
+ @prefix = opts[:prefix] || DEFAULT_PREFIX
41
43
 
42
44
  system = SystemStatistics.new(opts[:system] || {})
43
45
 
@@ -72,6 +74,7 @@ module FFWD::Statistics
72
74
  def generate! last, now
73
75
  if @system
74
76
  @system.collect @channel do |key, value|
77
+ key = "#{@prefix}.#{key}"
75
78
  @emitter.metric.emit(
76
79
  :key => key, :value => value,
77
80
  :tags => @tags, :attributes => @attributes)
@@ -81,8 +84,9 @@ module FFWD::Statistics
81
84
  @reporters.each do |id, reporter|
82
85
  reporter.report! do |d|
83
86
  attributes = FFWD.merge_hashes @attributes, d[:meta]
87
+ key = "#{@prefix}.#{d[:key]}"
84
88
  @emitter.metric.emit(
85
- :key => d[:key], :value => d[:value],
89
+ :key => key, :value => d[:value],
86
90
  :tags => @tags, :attributes => attributes)
87
91
  end
88
92
  end
@@ -103,11 +103,11 @@ module FFWD::Statistics
103
103
  cpu_use = cpu_usage
104
104
 
105
105
  cpu_use.each do |key, value|
106
- yield "statistics-cpu/#{key}", value
106
+ yield "statistics.cpu-#{key}", value
107
107
  end
108
108
 
109
109
  memory_use.each do |key, value|
110
- yield "statistics-memory/#{key}", value
110
+ yield "statistics.memory-#{key}", value
111
111
  end
112
112
 
113
113
  channel << {
data/lib/ffwd/version.rb CHANGED
@@ -14,5 +14,5 @@
14
14
  # the License.
15
15
 
16
16
  module FFWD
17
- VERSION = "0.1.1"
17
+ VERSION = "0.1.2"
18
18
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffwd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - John-John Tedro
@@ -10,70 +9,62 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-03-02 00:00:00.000000000 Z
12
+ date: 2014-03-03 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: eventmachine
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rspec
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec-mocks
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: autoversion
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  description:
@@ -86,88 +77,87 @@ executables:
86
77
  extensions: []
87
78
  extra_rdoc_files: []
88
79
  files:
89
- - bin/ffwd
90
80
  - bin/fwc
81
+ - bin/ffwd
82
+ - lib/fwc.rb
83
+ - lib/ffwd.rb
84
+ - lib/ffwd/statistics.rb
85
+ - lib/ffwd/processor.rb
91
86
  - lib/ffwd/producing_client.rb
92
- - lib/ffwd/tunnel/udp.rb
93
- - lib/ffwd/tunnel/plugin.rb
94
- - lib/ffwd/tunnel/tcp.rb
87
+ - lib/ffwd/tunnel.rb
88
+ - lib/ffwd/protocol.rb
95
89
  - lib/ffwd/lifecycle.rb
96
- - lib/ffwd/logging.rb
97
- - lib/ffwd/metric.rb
98
- - lib/ffwd/schema.rb
99
- - lib/ffwd/version.rb
100
- - lib/ffwd/statistics/collector.rb
90
+ - lib/ffwd/debug/tcp.rb
91
+ - lib/ffwd/debug/connection.rb
92
+ - lib/ffwd/debug/monitor_session.rb
93
+ - lib/ffwd/channel.rb
94
+ - lib/ffwd/plugin/json.rb
95
+ - lib/ffwd/plugin/log/writer.rb
96
+ - lib/ffwd/plugin/log.rb
97
+ - lib/ffwd/plugin/json/connection.rb
98
+ - lib/ffwd/circular_buffer.rb
99
+ - lib/ffwd/event.rb
101
100
  - lib/ffwd/statistics/system_statistics.rb
101
+ - lib/ffwd/statistics/collector.rb
102
+ - lib/ffwd/connection.rb
102
103
  - lib/ffwd/utils.rb
103
- - lib/ffwd/protocol/udp.rb
104
+ - lib/ffwd/protocol/tcp.rb
104
105
  - lib/ffwd/protocol/tcp/bind.rb
105
- - lib/ffwd/protocol/tcp/flushing_connect.rb
106
106
  - lib/ffwd/protocol/tcp/plain_connect.rb
107
+ - lib/ffwd/protocol/tcp/flushing_connect.rb
107
108
  - lib/ffwd/protocol/tcp/connection.rb
108
- - lib/ffwd/protocol/tcp.rb
109
109
  - lib/ffwd/protocol/udp/bind.rb
110
110
  - lib/ffwd/protocol/udp/connect.rb
111
- - lib/ffwd/plugin/log/writer.rb
112
- - lib/ffwd/plugin/log.rb
113
- - lib/ffwd/plugin/json.rb
114
- - lib/ffwd/plugin/json/connection.rb
115
- - lib/ffwd/handler.rb
116
- - lib/ffwd/protocol.rb
117
- - lib/ffwd/plugin.rb
118
- - lib/ffwd/debug.rb
119
- - lib/ffwd/event.rb
120
- - lib/ffwd/processor.rb
121
- - lib/ffwd/debug/monitor_session.rb
122
- - lib/ffwd/debug/tcp.rb
123
- - lib/ffwd/debug/connection.rb
124
- - lib/ffwd/channel.rb
125
- - lib/ffwd/circular_buffer.rb
126
- - lib/ffwd/core/interface.rb
127
- - lib/ffwd/core/emitter.rb
128
- - lib/ffwd/core/processor.rb
129
- - lib/ffwd/core/reporter.rb
130
- - lib/ffwd/core.rb
131
- - lib/ffwd/plugin_channel.rb
132
- - lib/ffwd/plugin_loader.rb
111
+ - lib/ffwd/protocol/udp.rb
133
112
  - lib/ffwd/reporter.rb
134
- - lib/ffwd/metric_emitter.rb
135
- - lib/ffwd/statistics.rb
113
+ - lib/ffwd/plugin_loader.rb
136
114
  - lib/ffwd/schema/spotify100.rb
137
115
  - lib/ffwd/schema/default.rb
138
- - lib/ffwd/retrier.rb
139
- - lib/ffwd/tunnel.rb
116
+ - lib/ffwd/metric_emitter.rb
117
+ - lib/ffwd/schema.rb
118
+ - lib/ffwd/event_emitter.rb
119
+ - lib/ffwd/core/processor.rb
120
+ - lib/ffwd/core/interface.rb
121
+ - lib/ffwd/core/reporter.rb
122
+ - lib/ffwd/core/emitter.rb
123
+ - lib/ffwd/handler.rb
124
+ - lib/ffwd/version.rb
125
+ - lib/ffwd/core.rb
126
+ - lib/ffwd/processor/rate.rb
140
127
  - lib/ffwd/processor/count.rb
141
128
  - lib/ffwd/processor/histogram.rb
142
- - lib/ffwd/processor/rate.rb
143
- - lib/ffwd/event_emitter.rb
144
- - lib/ffwd/connection.rb
145
- - lib/ffwd.rb
129
+ - lib/ffwd/debug.rb
130
+ - lib/ffwd/retrier.rb
131
+ - lib/ffwd/logging.rb
132
+ - lib/ffwd/plugin_channel.rb
133
+ - lib/ffwd/tunnel/tcp.rb
134
+ - lib/ffwd/tunnel/udp.rb
135
+ - lib/ffwd/tunnel/plugin.rb
136
+ - lib/ffwd/plugin.rb
137
+ - lib/ffwd/metric.rb
146
138
  - lib/em/all.rb
147
- - lib/fwc.rb
148
139
  homepage: https://github.com/spotify/ffwd
149
140
  licenses:
150
141
  - Apache 2.0
142
+ metadata: {}
151
143
  post_install_message:
152
144
  rdoc_options: []
153
145
  require_paths:
154
146
  - lib
155
147
  required_ruby_version: !ruby/object:Gem::Requirement
156
- none: false
157
148
  requirements:
158
- - - ! '>='
149
+ - - '>='
159
150
  - !ruby/object:Gem::Version
160
151
  version: '0'
161
152
  required_rubygems_version: !ruby/object:Gem::Requirement
162
- none: false
163
153
  requirements:
164
- - - ! '>='
154
+ - - '>='
165
155
  - !ruby/object:Gem::Version
166
156
  version: '0'
167
157
  requirements: []
168
158
  rubyforge_project:
169
- rubygems_version: 1.8.23
159
+ rubygems_version: 2.0.3
170
160
  signing_key:
171
- specification_version: 3
161
+ specification_version: 4
172
162
  summary: Core framework for the FastForward Daemon.
173
163
  test_files: []