ffwd 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 +7 -0
- data/lib/ffwd.rb +34 -10
- data/lib/ffwd/core.rb +13 -11
- data/lib/ffwd/core/emitter.rb +0 -2
- data/lib/ffwd/core/interface.rb +5 -2
- data/lib/ffwd/core/processor.rb +4 -5
- data/lib/ffwd/debug/monitor_session.rb +3 -6
- data/lib/ffwd/debug/tcp.rb +17 -12
- data/lib/ffwd/handler.rb +1 -1
- data/lib/ffwd/plugin.rb +20 -15
- data/lib/ffwd/plugin/json.rb +12 -20
- data/lib/ffwd/plugin/json/connection.rb +4 -2
- data/lib/ffwd/plugin/log.rb +17 -2
- data/lib/ffwd/plugin/log/writer.rb +4 -0
- data/lib/ffwd/plugin_channel.rb +8 -8
- data/lib/ffwd/processor.rb +11 -4
- data/lib/ffwd/processor/count.rb +16 -6
- data/lib/ffwd/processor/histogram.rb +26 -15
- data/lib/ffwd/processor/rate.rb +16 -6
- data/lib/ffwd/protocol/tcp.rb +47 -88
- data/lib/ffwd/protocol/tcp/bind.rb +22 -10
- data/lib/ffwd/protocol/tcp/connection.rb +23 -6
- data/lib/ffwd/protocol/tcp/flushing_connect.rb +42 -25
- data/lib/ffwd/protocol/tcp/plain_connect.rb +15 -3
- data/lib/ffwd/protocol/udp.rb +42 -17
- data/lib/ffwd/protocol/udp/bind.rb +21 -10
- data/lib/ffwd/protocol/udp/connect.rb +22 -9
- data/lib/ffwd/retrier.rb +4 -1
- data/lib/ffwd/schema.rb +10 -3
- data/lib/ffwd/statistics/collector.rb +31 -23
- data/lib/ffwd/test/protocol.rb +42 -0
- data/lib/ffwd/tunnel/tcp.rb +3 -1
- data/lib/ffwd/utils.rb +7 -0
- data/lib/ffwd/version.rb +1 -1
- metadata +56 -68
- data/lib/ffwd/circular_buffer.rb +0 -78
- data/lib/ffwd/statistics.rb +0 -29
- data/lib/ffwd/tunnel.rb +0 -27
data/lib/ffwd/schema.rb
CHANGED
@@ -22,9 +22,16 @@ module FFWD
|
|
22
22
|
DEFUALT_SCHEMA = 'default'
|
23
23
|
DEFAULT_CONTENT_TYPE = 'application/json'
|
24
24
|
|
25
|
-
def self.
|
26
|
-
|
27
|
-
|
25
|
+
def self.prepare_schema config
|
26
|
+
config[:schema] ||= DEFUALT_SCHEMA
|
27
|
+
config[:content_type] ||= DEFAULT_CONTENT_TYPE
|
28
|
+
config
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.parse_schema config, support=SCHEMA_DEFAULT_SUPPORT
|
32
|
+
name = config[:schema]
|
33
|
+
content_type = config[:content_type]
|
34
|
+
|
28
35
|
key = [name, content_type]
|
29
36
|
|
30
37
|
schema = FFWD::Schema.loaded[key]
|
@@ -14,16 +14,28 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
require_relative '../lifecycle'
|
17
|
+
require_relative '../logging'
|
17
18
|
|
18
19
|
require_relative 'system_statistics'
|
19
20
|
|
20
21
|
module FFWD::Statistics
|
21
22
|
class Collector
|
22
23
|
include FFWD::Lifecycle
|
24
|
+
include FFWD::Logging
|
23
25
|
|
24
26
|
DEFAULT_PERIOD = 10
|
25
27
|
DEFAULT_PREFIX = "ffwd"
|
26
28
|
|
29
|
+
def self.build emitter, channel, opts={}
|
30
|
+
opts[:period] ||= DEFAULT_PERIOD
|
31
|
+
opts[:prefix] ||= DEFAULT_PREFIX
|
32
|
+
opts[:tags] ||= []
|
33
|
+
opts[:attributes] ||= {}
|
34
|
+
system = SystemStatistics.new(opts[:system] || {})
|
35
|
+
system = if system.check then system end
|
36
|
+
new emitter, channel, system, opts
|
37
|
+
end
|
38
|
+
|
27
39
|
# Initialize the statistics collector.
|
28
40
|
#
|
29
41
|
# emitter - The emitter used to dispatch metrics for all reporters and
|
@@ -31,27 +43,19 @@ module FFWD::Statistics
|
|
31
43
|
# channel - A side-channel used by the SystemStatistics component
|
32
44
|
# to report information about the system. Messages sent on this channel
|
33
45
|
# help Core decide if it should seppuku.
|
34
|
-
def initialize
|
46
|
+
def initialize emitter, channel, system, opts
|
35
47
|
@emitter = emitter
|
36
|
-
@period = opts[:period] || DEFAULT_PERIOD
|
37
|
-
@tags = opts[:tags] || []
|
38
|
-
@attributes = opts[:attributes] || {}
|
39
|
-
@reporters = {}
|
40
48
|
@channel = channel
|
41
|
-
@
|
42
|
-
@
|
49
|
+
@system = system
|
50
|
+
@period = opts[:period]
|
51
|
+
@prefix = opts[:prefix]
|
52
|
+
@tags = opts[:tags]
|
53
|
+
@attributes = opts[:attributes]
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
if system.check
|
47
|
-
@system = system
|
48
|
-
else
|
49
|
-
@system = nil
|
50
|
-
end
|
55
|
+
@reporters = {}
|
56
|
+
@timer = nil
|
51
57
|
|
52
58
|
starting do
|
53
|
-
log.info "Started statistics collection"
|
54
|
-
|
55
59
|
@last = Time.now
|
56
60
|
|
57
61
|
@timer = EM::PeriodicTimer.new @period do
|
@@ -59,15 +63,17 @@ module FFWD::Statistics
|
|
59
63
|
generate! @last, now
|
60
64
|
@last = now
|
61
65
|
end
|
66
|
+
|
67
|
+
log.info "Started #{opts.inspect}"
|
62
68
|
end
|
63
69
|
|
64
70
|
stopping do
|
65
|
-
log.info "Stopped statistics collection"
|
66
|
-
|
67
71
|
if @timer
|
68
72
|
@timer.cancel
|
69
73
|
@timer = nil
|
70
74
|
end
|
75
|
+
|
76
|
+
log.info "Stopped"
|
71
77
|
end
|
72
78
|
end
|
73
79
|
|
@@ -92,12 +98,14 @@ module FFWD::Statistics
|
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
95
|
-
def register id, reporter
|
96
|
-
|
97
|
-
|
101
|
+
def register lifecycle, id, reporter
|
102
|
+
lifecycle.starting do
|
103
|
+
@reporters[id] = reporter
|
104
|
+
end
|
98
105
|
|
99
|
-
|
100
|
-
|
106
|
+
lifecycle.stopping do
|
107
|
+
@reporters.delete id
|
108
|
+
end
|
101
109
|
end
|
102
110
|
end
|
103
111
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# $LICENSE
|
2
|
+
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
+
#
|
4
|
+
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
+
# (the "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'ffwd/handler'
|
17
|
+
require 'ffwd/connection'
|
18
|
+
|
19
|
+
module FFWD::Test
|
20
|
+
module Protocol
|
21
|
+
def valid_output klass, opts={}
|
22
|
+
expect(klass < FFWD::Handler).to be true
|
23
|
+
sig = double
|
24
|
+
connect = double
|
25
|
+
config = opts[:config] || double
|
26
|
+
expect(klass.respond_to?(:plugin_type)).to be true
|
27
|
+
expect(klass.plugin_type.nil?).to be false
|
28
|
+
return klass.new sig, connect, config
|
29
|
+
end
|
30
|
+
|
31
|
+
def valid_input klass, opts={}
|
32
|
+
expect(klass < FFWD::Connection).to be true
|
33
|
+
sig = double
|
34
|
+
bind = double
|
35
|
+
core = double
|
36
|
+
config = opts[:config] || double
|
37
|
+
expect(klass.respond_to?(:plugin_type)).to be true
|
38
|
+
expect(klass.plugin_type.nil?).to be false
|
39
|
+
return klass.new sig, bind, core, config
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/ffwd/tunnel/tcp.rb
CHANGED
data/lib/ffwd/utils.rb
CHANGED
@@ -47,4 +47,11 @@ module FFWD
|
|
47
47
|
def self.dump2hex data
|
48
48
|
data.bytes.map { |byte| byte.to_s(16) }.join
|
49
49
|
end
|
50
|
+
|
51
|
+
def self.check_ignored v
|
52
|
+
v = v.to_s
|
53
|
+
return :metrics if v.downcase == "metrics"
|
54
|
+
return :events if v.downcase == "events"
|
55
|
+
raise "Invalid ignore kind '#{v}', should be one of: 'metrics' or 'events'"
|
56
|
+
end
|
50
57
|
end
|
data/lib/ffwd/version.rb
CHANGED
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.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
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-
|
12
|
+
date: 2014-06-02 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,89 +77,86 @@ 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/processor.rb
|
91
85
|
- lib/ffwd/producing_client.rb
|
92
|
-
- lib/ffwd/
|
93
|
-
- lib/ffwd/tunnel/plugin.rb
|
94
|
-
- lib/ffwd/tunnel/tcp.rb
|
86
|
+
- lib/ffwd/protocol.rb
|
95
87
|
- lib/ffwd/lifecycle.rb
|
96
|
-
- lib/ffwd/
|
97
|
-
- lib/ffwd/
|
98
|
-
- lib/ffwd/
|
99
|
-
- lib/ffwd/
|
100
|
-
- lib/ffwd/
|
88
|
+
- lib/ffwd/debug/tcp.rb
|
89
|
+
- lib/ffwd/debug/connection.rb
|
90
|
+
- lib/ffwd/debug/monitor_session.rb
|
91
|
+
- lib/ffwd/channel.rb
|
92
|
+
- lib/ffwd/test/protocol.rb
|
93
|
+
- lib/ffwd/plugin/json.rb
|
94
|
+
- lib/ffwd/plugin/log/writer.rb
|
95
|
+
- lib/ffwd/plugin/log.rb
|
96
|
+
- lib/ffwd/plugin/json/connection.rb
|
97
|
+
- lib/ffwd/event.rb
|
101
98
|
- lib/ffwd/statistics/system_statistics.rb
|
99
|
+
- lib/ffwd/statistics/collector.rb
|
100
|
+
- lib/ffwd/connection.rb
|
102
101
|
- lib/ffwd/utils.rb
|
103
|
-
- lib/ffwd/protocol/
|
102
|
+
- lib/ffwd/protocol/tcp.rb
|
104
103
|
- lib/ffwd/protocol/tcp/bind.rb
|
105
|
-
- lib/ffwd/protocol/tcp/flushing_connect.rb
|
106
104
|
- lib/ffwd/protocol/tcp/plain_connect.rb
|
105
|
+
- lib/ffwd/protocol/tcp/flushing_connect.rb
|
107
106
|
- lib/ffwd/protocol/tcp/connection.rb
|
108
|
-
- lib/ffwd/protocol/tcp.rb
|
109
107
|
- lib/ffwd/protocol/udp/bind.rb
|
110
108
|
- lib/ffwd/protocol/udp/connect.rb
|
111
|
-
- lib/ffwd/
|
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
|
109
|
+
- lib/ffwd/protocol/udp.rb
|
133
110
|
- lib/ffwd/reporter.rb
|
134
|
-
- lib/ffwd/
|
135
|
-
- lib/ffwd/statistics.rb
|
111
|
+
- lib/ffwd/plugin_loader.rb
|
136
112
|
- lib/ffwd/schema/spotify100.rb
|
137
113
|
- lib/ffwd/schema/default.rb
|
138
|
-
- lib/ffwd/
|
139
|
-
- lib/ffwd/
|
114
|
+
- lib/ffwd/metric_emitter.rb
|
115
|
+
- lib/ffwd/schema.rb
|
116
|
+
- lib/ffwd/event_emitter.rb
|
117
|
+
- lib/ffwd/core/processor.rb
|
118
|
+
- lib/ffwd/core/interface.rb
|
119
|
+
- lib/ffwd/core/reporter.rb
|
120
|
+
- lib/ffwd/core/emitter.rb
|
121
|
+
- lib/ffwd/handler.rb
|
122
|
+
- lib/ffwd/version.rb
|
123
|
+
- lib/ffwd/core.rb
|
124
|
+
- lib/ffwd/processor/rate.rb
|
140
125
|
- lib/ffwd/processor/count.rb
|
141
126
|
- lib/ffwd/processor/histogram.rb
|
142
|
-
- lib/ffwd/
|
143
|
-
- lib/ffwd/
|
144
|
-
- lib/ffwd/
|
145
|
-
- lib/ffwd.rb
|
127
|
+
- lib/ffwd/debug.rb
|
128
|
+
- lib/ffwd/retrier.rb
|
129
|
+
- lib/ffwd/logging.rb
|
130
|
+
- lib/ffwd/plugin_channel.rb
|
131
|
+
- lib/ffwd/tunnel/tcp.rb
|
132
|
+
- lib/ffwd/tunnel/udp.rb
|
133
|
+
- lib/ffwd/tunnel/plugin.rb
|
134
|
+
- lib/ffwd/plugin.rb
|
135
|
+
- lib/ffwd/metric.rb
|
146
136
|
- lib/em/protocols/frame_object_protocol.rb
|
147
137
|
- lib/em/all.rb
|
148
|
-
- lib/fwc.rb
|
149
138
|
homepage: https://github.com/spotify/ffwd
|
150
139
|
licenses:
|
151
140
|
- Apache 2.0
|
141
|
+
metadata: {}
|
152
142
|
post_install_message:
|
153
143
|
rdoc_options: []
|
154
144
|
require_paths:
|
155
145
|
- lib
|
156
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
-
none: false
|
158
147
|
requirements:
|
159
|
-
- -
|
148
|
+
- - '>='
|
160
149
|
- !ruby/object:Gem::Version
|
161
150
|
version: '0'
|
162
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
152
|
requirements:
|
165
|
-
- -
|
153
|
+
- - '>='
|
166
154
|
- !ruby/object:Gem::Version
|
167
155
|
version: '0'
|
168
156
|
requirements: []
|
169
157
|
rubyforge_project:
|
170
|
-
rubygems_version:
|
158
|
+
rubygems_version: 2.0.3
|
171
159
|
signing_key:
|
172
|
-
specification_version:
|
160
|
+
specification_version: 4
|
173
161
|
summary: Core framework for the FastForward Daemon.
|
174
162
|
test_files: []
|
data/lib/ffwd/circular_buffer.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# $LICENSE
|
2
|
-
# Copyright 2013-2014 Spotify AB. All rights reserved.
|
3
|
-
#
|
4
|
-
# The contents of this file are licensed under the Apache License, Version 2.0
|
5
|
-
# (the "License"); you may not use this file except in compliance with the
|
6
|
-
# License. You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
Node = Struct.new(:value, :next)
|
17
|
-
|
18
|
-
module FFWD
|
19
|
-
class CircularBuffer
|
20
|
-
attr_reader :buffer, :capacity, :size
|
21
|
-
|
22
|
-
def initialize capacity
|
23
|
-
@capacity = capacity
|
24
|
-
@first = nil
|
25
|
-
@last = nil
|
26
|
-
@size = 0
|
27
|
-
end
|
28
|
-
|
29
|
-
def clear
|
30
|
-
@first = nil
|
31
|
-
@last = nil
|
32
|
-
@size = 0
|
33
|
-
end
|
34
|
-
|
35
|
-
def empty?
|
36
|
-
size == 0
|
37
|
-
end
|
38
|
-
|
39
|
-
def peek
|
40
|
-
return nil if @first.nil?
|
41
|
-
@first.value
|
42
|
-
end
|
43
|
-
|
44
|
-
def shift
|
45
|
-
return nil if @first.nil?
|
46
|
-
value = @first.value
|
47
|
-
@first = @first.next
|
48
|
-
@last = nil if @first.nil?
|
49
|
-
@size -= 1
|
50
|
-
value
|
51
|
-
end
|
52
|
-
|
53
|
-
def << item
|
54
|
-
node = Node.new(item, nil)
|
55
|
-
|
56
|
-
if @last.nil?
|
57
|
-
@first = @last = node
|
58
|
-
else
|
59
|
-
@last = @last.next = node
|
60
|
-
end
|
61
|
-
|
62
|
-
if @size >= @capacity
|
63
|
-
@first = @first.next
|
64
|
-
else
|
65
|
-
@size += 1
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def each
|
70
|
-
current = @first
|
71
|
-
|
72
|
-
while not current.nil?
|
73
|
-
yield current.value
|
74
|
-
current = current.next
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|