fluent-plugin-redis_list_poller 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +10 -1
- data/examples/standalone.conf +5 -1
- data/fluent-plugin-redis_list_poller.gemspec +2 -2
- data/lib/fluent/plugin/in_redis_list_monitor.rb +7 -48
- data/lib/fluent/plugin/in_redis_list_poller.rb +28 -54
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe11a0f3a75660f2f69728aaa3b0eab0981e4a25
|
4
|
+
data.tar.gz: b9315ebc6d800236eeb92d76c7834cfb2ec2460c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a1f9d2fd8ca1e2988e1475b824de37e778ff7fcf9e34b7eb9ace0a8b508fbfb4be10037621af1c7e0cb06fa223a618232362ca88bae42b61d3c1f5035696a56
|
7
|
+
data.tar.gz: 7c5993c33b32436db596fbe95c6b2cc0a8f5234778a4202d88bbac9c135c7d59d6177139e173b72b38742a58bf69b613f1b0c85e634efe5bbbdbf5a404e7ddbb
|
data/CHANGELOG.txt
CHANGED
data/examples/standalone.conf
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "fluent-plugin-redis_list_poller"
|
5
|
-
spec.version = "
|
5
|
+
spec.version = "1.0.0"
|
6
6
|
spec.authors = ["Jonathan Serafini"]
|
7
7
|
spec.email = ["jonathan@serafini.ca"]
|
8
8
|
|
@@ -18,5 +18,5 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.add_development_dependency "bundler"
|
19
19
|
spec.add_development_dependency "rake"
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "fluentd", [">= 0.
|
21
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
|
22
22
|
end
|
@@ -7,9 +7,10 @@ module Fluent
|
|
7
7
|
# output metrics to the login pipeline.
|
8
8
|
# @since 0.1.0
|
9
9
|
class RedisListMonitorInput < Input
|
10
|
-
include Fluent::PluginMixin::Redis
|
11
|
-
|
12
10
|
Plugin.register_input('redis_list_monitor', self)
|
11
|
+
|
12
|
+
include Fluent::PluginMixin::Redis
|
13
|
+
helpers :timer
|
13
14
|
|
14
15
|
# input plugin parameters
|
15
16
|
config_param :tag, :string, :default => nil
|
@@ -19,7 +20,6 @@ module Fluent
|
|
19
20
|
# @return [NilClass]
|
20
21
|
def initialize
|
21
22
|
super
|
22
|
-
require 'cool.io'
|
23
23
|
end
|
24
24
|
|
25
25
|
# Initialize attributes and parameters
|
@@ -63,44 +63,22 @@ module Fluent
|
|
63
63
|
def start
|
64
64
|
super
|
65
65
|
|
66
|
-
@loop = Coolio::Loop.new
|
67
|
-
|
68
66
|
start_redis
|
69
67
|
start_poller
|
70
|
-
|
71
|
-
@thread = Thread.new(&method(:run))
|
72
68
|
end
|
73
69
|
|
74
70
|
def start_poller
|
75
|
-
@
|
76
|
-
|
77
|
-
|
78
|
-
&method(:action_poll)
|
79
|
-
)
|
80
|
-
|
81
|
-
@loop.attach(@poller)
|
82
|
-
end
|
83
|
-
|
84
|
-
# Begin the logging pipeline
|
85
|
-
# @since 0.1.0
|
86
|
-
# @return [NilClass]
|
87
|
-
def run
|
88
|
-
@loop.run
|
89
|
-
rescue => e
|
90
|
-
log.error "unexpected error", :error => e
|
91
|
-
log.error_backtrace
|
71
|
+
timer_execute(:poll, @poll_interval) do
|
72
|
+
action_poll
|
73
|
+
end
|
92
74
|
end
|
93
75
|
|
94
76
|
# Tear down the plugin
|
95
77
|
# @since 0.1.0
|
96
78
|
# @return [NilClass]
|
97
79
|
def shutdown
|
98
|
-
@loop.watchers.each { |w| w.detach }
|
99
|
-
@loop.stop
|
100
|
-
Thread.kill(@thread)
|
101
|
-
@thread.join
|
102
|
-
shutdown_redis
|
103
80
|
super
|
81
|
+
shutdown_redis
|
104
82
|
end
|
105
83
|
|
106
84
|
# Wether the poller has been temporarily disabled or should fetch messages
|
@@ -150,25 +128,6 @@ module Fluent
|
|
150
128
|
log.error_backtrace
|
151
129
|
sleep!(@retry_interval)
|
152
130
|
end
|
153
|
-
|
154
|
-
# Generic Cool.io timer which will execute a given callback on schedule.
|
155
|
-
# @since 0.1.0
|
156
|
-
class TimerWatcher < Coolio::TimerWatcher
|
157
|
-
attr_reader :log
|
158
|
-
|
159
|
-
def initialize(interval, log, &callback)
|
160
|
-
@callback = callback
|
161
|
-
@log = log
|
162
|
-
super(interval, true)
|
163
|
-
end
|
164
|
-
|
165
|
-
def on_timer
|
166
|
-
@callback.call
|
167
|
-
rescue => e
|
168
|
-
log.error "unexpected error", :error=>e
|
169
|
-
log.error_backtrace
|
170
|
-
end
|
171
|
-
end
|
172
131
|
end
|
173
132
|
end
|
174
133
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require "fluent/plugin/input"
|
2
|
+
require "fluent/plugin/parser"
|
3
|
+
require 'fluent/process'
|
2
4
|
require "fluent/plugin_mixin/redis"
|
3
5
|
|
4
6
|
module Fluent
|
@@ -7,8 +9,8 @@ module Fluent
|
|
7
9
|
include Fluent::PluginMixin::Redis
|
8
10
|
|
9
11
|
Plugin.register_input('redis_list_poller', self)
|
10
|
-
|
11
12
|
helpers :storage
|
13
|
+
helpers :timer
|
12
14
|
|
13
15
|
# redis list details
|
14
16
|
# - command: redis command to execute when fetching messages
|
@@ -18,14 +20,17 @@ module Fluent
|
|
18
20
|
|
19
21
|
# input plugin parameters
|
20
22
|
config_param :tag, :string, :default => nil
|
21
|
-
|
23
|
+
|
24
|
+
# parser plugin parameters
|
25
|
+
config_section :parse, :init => true, :multi => false do
|
26
|
+
config_set_default :@type, "json"
|
27
|
+
end
|
22
28
|
|
23
29
|
# Initialize new input plugin
|
24
30
|
# @since 0.1.0
|
25
31
|
# @return [NilClass]
|
26
32
|
def initialize
|
27
33
|
super
|
28
|
-
require 'cool.io'
|
29
34
|
require 'msgpack'
|
30
35
|
end
|
31
36
|
|
@@ -46,7 +51,7 @@ module Fluent
|
|
46
51
|
# @since 0.1.0
|
47
52
|
# @return [NilClass]
|
48
53
|
def configure_params(config)
|
49
|
-
%w(host port key command
|
54
|
+
%w(host port key command tag).each do |key|
|
50
55
|
next if instance_variable_get("@#{key}")
|
51
56
|
raise Fluent::ConfigError, "configuration key missing: #{key}"
|
52
57
|
end
|
@@ -60,8 +65,10 @@ module Fluent
|
|
60
65
|
# @since 0.1.0
|
61
66
|
# @return [NilClass]
|
62
67
|
def configure_parser(config)
|
63
|
-
|
64
|
-
@
|
68
|
+
parser_config = @parse.corresponding_config_element
|
69
|
+
parser_type = parser_config['@type']
|
70
|
+
@parser = Fluent::Plugin.new_parser(parser_type, :parent => self)
|
71
|
+
@parser.configure(parser_config)
|
65
72
|
end
|
66
73
|
|
67
74
|
# Configure locking
|
@@ -81,11 +88,9 @@ module Fluent
|
|
81
88
|
# @return [NilClass]
|
82
89
|
def start
|
83
90
|
super
|
84
|
-
|
85
|
-
@loop = Coolio::Loop.new
|
86
91
|
start_redis
|
87
92
|
start_poller
|
88
|
-
|
93
|
+
start_monitor
|
89
94
|
end
|
90
95
|
|
91
96
|
# Prepare the Redis queue poller
|
@@ -96,42 +101,30 @@ module Fluent
|
|
96
101
|
# @since 0.1.0
|
97
102
|
# @return [NilClass]
|
98
103
|
def start_poller
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
&method(:action_poll)
|
103
|
-
)
|
104
|
-
|
105
|
-
@lock_monitor = TimerWatcher.new(
|
106
|
-
1,
|
107
|
-
log,
|
108
|
-
&method(:action_locking_monitor)
|
109
|
-
)
|
110
|
-
|
111
|
-
@loop.attach(@poller)
|
112
|
-
@loop.attach(@lock_monitor)
|
104
|
+
timer_execute(:poller, @poll_interval) do
|
105
|
+
action_poll
|
106
|
+
end
|
113
107
|
end
|
114
108
|
|
115
|
-
#
|
116
|
-
#
|
109
|
+
# Prepare the Redis queue monitor
|
110
|
+
#
|
111
|
+
# This timed event will routinely poll for a lock key and disable the
|
112
|
+
# queue poller if required
|
113
|
+
#
|
114
|
+
# @since 0.1.1
|
117
115
|
# @return [NilClass]
|
118
|
-
def
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
log.error_backtrace
|
116
|
+
def start_monitor
|
117
|
+
timer_execute(:monitor, 1) do
|
118
|
+
action_locking_monitor
|
119
|
+
end
|
123
120
|
end
|
124
121
|
|
125
122
|
# Tear down the plugin
|
126
123
|
# @since 0.1.0
|
127
124
|
# @return [NilClass]
|
128
125
|
def shutdown
|
129
|
-
@loop.watchers.each { |w| w.detach }
|
130
|
-
@loop.stop
|
131
|
-
Thread.kill(@thread)
|
132
|
-
@thread.join
|
133
|
-
shutdown_redis
|
134
126
|
super
|
127
|
+
shutdown_redis
|
135
128
|
end
|
136
129
|
|
137
130
|
# Whether to fetch a single item or a multiple items in batch
|
@@ -239,25 +232,6 @@ module Fluent
|
|
239
232
|
log.error_backtrace
|
240
233
|
sleep!(@retry_interval)
|
241
234
|
end
|
242
|
-
|
243
|
-
# Generic Cool.io timer which will execute a given callback on schedule.
|
244
|
-
# @since 0.1.0
|
245
|
-
class TimerWatcher < Coolio::TimerWatcher
|
246
|
-
attr_reader :log
|
247
|
-
|
248
|
-
def initialize(interval, log, &callback)
|
249
|
-
@callback = callback
|
250
|
-
@log = log
|
251
|
-
super(interval, true)
|
252
|
-
end
|
253
|
-
|
254
|
-
def on_timer
|
255
|
-
@callback.call
|
256
|
-
rescue => e
|
257
|
-
log.error "unexpected error", :error => e
|
258
|
-
log.error_backtrace
|
259
|
-
end
|
260
|
-
end
|
261
235
|
end
|
262
236
|
end
|
263
237
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-redis_list_poller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Serafini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.14.0
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '2'
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.
|
57
|
+
version: 0.14.0
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '2'
|