fluent-plugin-mqtt-io 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1ec56bcb964c914765afcd471b69413e623a54d
4
- data.tar.gz: d7784e5b1e39d416cec4b40a1868ca72fe0f3afc
3
+ metadata.gz: 97803d6c5941eb7ff068d9d8e7205c9a78cc629b
4
+ data.tar.gz: 8f492394371c32718ad1f97181597efe2192bf08
5
5
  SHA512:
6
- metadata.gz: 62e831aece6900ea1b8f3b8b98fae4cf0391c2bf223803dba5ba8aecd2182c103172523793721ab25bf5279f266e193a3dd4bf86b79167c51b197d44e9ea9475
7
- data.tar.gz: 3efb8116780288682a990f56c98b4b338a7823e037f9a5088e62071d537b9d2e330841bb06fb68b4adb02ac90ffd93382b1694ef13557cb288326795a3f2c167
6
+ metadata.gz: a022d9dd82ed38ced4b9cfc89e7d01da5cca628dd6030bc36687df3594409dc25953a027ab9a5a2390f3aa7ef12081114b46c81311d8904a52e342f71f14cd3c
7
+ data.tar.gz: 00e999e1448d738401eca559d54670c2dff6586f534342af9d09c9caf3f9f745b4bcbbc3704e55210b55485f7bf210e8cce54c21358ce96c00b8be3a0728802b
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-mqtt-io"
7
- spec.version = "0.3.0"
7
+ spec.version = "0.3.1"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -12,48 +12,48 @@ module Fluent::Plugin
12
12
  MQTT_PORT = 1883
13
13
 
14
14
  desc 'The address to connect to.'
15
- config_param :host, :string, :default => '127.0.0.1'
15
+ config_param :host, :string, default: '127.0.0.1'
16
16
  desc 'The port to connect to.'
17
- config_param :port, :integer, :default => MQTT_PORT
17
+ config_param :port, :integer, default: MQTT_PORT
18
18
  desc 'The topic to subscribe.'
19
- config_param :topic, :string, :default => '#'
19
+ config_param :topic, :string, default: '#'
20
20
  desc 'The format to receive.'
21
- config_param :format, :string, :default => 'json'
21
+ config_param :format, :string, default: 'json'
22
22
  desc 'Specify keep alive interval.'
23
- config_param :keep_alive, :integer, :default => 15
23
+ config_param :keep_alive, :integer, default: 15
24
24
  desc 'Specify initial interval for reconnection.'
25
- config_param :initial_interval, :integer, :default => 1
25
+ config_param :initial_interval, :integer, default: 1
26
26
  desc 'Specify increasing ratio of reconnection interval.'
27
- config_param :retry_inc_ratio, :integer, :default => 2
27
+ config_param :retry_inc_ratio, :integer, default: 2
28
28
 
29
29
  # bulk_trans is deprecated
30
30
  # multiple entries must be inputted as an Array
31
- #config_param :bulk_trans, :bool, :default => true
32
- #config_param :bulk_trans_sep, :string, :default => "\t"
31
+ #config_param :bulk_trans, :bool, default: true
32
+ #config_param :bulk_trans_sep, :string, default: "\t"
33
33
 
34
34
  config_section :security, required: false, multi: false do
35
35
  ### User based authentication
36
36
  desc 'The username for authentication'
37
- config_param :username, :string, :default => nil
37
+ config_param :username, :string, default: nil
38
38
  desc 'The password for authentication'
39
- config_param :password, :string, :default => nil
39
+ config_param :password, :string, default: nil
40
40
  desc 'Use TLS or not.'
41
- config_param :use_tls, :bool, :default => nil
41
+ config_param :use_tls, :bool, default: nil
42
42
  config_section :tls, required: false, multi: true do
43
43
  desc 'Specify TLS ca file.'
44
- config_param :ca_file, :string, :default => nil
44
+ config_param :ca_file, :string, default: nil
45
45
  desc 'Specify TLS key file.'
46
- config_param :key_file, :string, :default => nil
46
+ config_param :key_file, :string, default: nil
47
47
  desc 'Specify TLS cert file.'
48
- config_param :cert_file, :string, :default => nil
48
+ config_param :cert_file, :string, default: nil
49
49
  end
50
50
  end
51
51
 
52
52
  config_section :monitor, required: false, multi: false do
53
53
  desc 'Record received time into message or not.'
54
- config_param :recv_time, :bool, :default => false
54
+ config_param :recv_time, :bool, default: false
55
55
  desc 'Specify the attribute name of received time.'
56
- config_param :recv_time_key, :string, :default => "recv_time"
56
+ config_param :recv_time_key, :string, default: "recv_time"
57
57
  end
58
58
 
59
59
  def configure(conf)
@@ -77,14 +77,14 @@ module Fluent::Plugin
77
77
  end
78
78
 
79
79
  def sleep_retry_interval(e, message)
80
- $log.error "#{message},#{e.class},#{e.message}"
81
- $log.error "Retry in #{@retry_interval} sec"
80
+ log.error "#{message},#{e.class},#{e.message}"
81
+ log.error "Retry in #{@retry_interval} sec"
82
82
  sleep @retry_interval
83
83
  increment_retry_interval
84
84
  end
85
85
 
86
86
  def start
87
- $log.debug "start mqtt #{@host}"
87
+ log.debug "start mqtt #{@host}"
88
88
  opts = {
89
89
  host: @host,
90
90
  port: @port,
@@ -140,7 +140,7 @@ module Fluent::Plugin
140
140
  def add_recv_time(record)
141
141
  if @recv_time
142
142
  # recv_time is recorded in ms
143
- record.merge({@recv_time_key => Fluent::EventTime.now})
143
+ record.merge({"#{@recv_time_key}": Fluent::EventTime.now})
144
144
  else
145
145
  record
146
146
  end
@@ -149,10 +149,10 @@ module Fluent::Plugin
149
149
  def parse(message)
150
150
  @parser.parse(message) do |time, record|
151
151
  if time.nil?
152
- $log.debug "Since time_key field is nil, Fluent::EventTime.now is used."
152
+ log.debug "Since time_key field is nil, Fluent::EventTime.now is used."
153
153
  time = Fluent::EventTime.now
154
154
  end
155
- $log.debug "#{topic}, #{time}, #{add_recv_time(record)}"
155
+ log.debug "#{topic}, #{time}, #{add_recv_time(record)}"
156
156
  return [time, add_recv_time(record)]
157
157
  end
158
158
  end
@@ -171,8 +171,8 @@ module Fluent::Plugin
171
171
  router.emit(tag, time, record)
172
172
  end
173
173
  rescue Exception => e
174
- $log.error :error => e.to_s
175
- $log.debug_backtrace(e.backtrace)
174
+ log.error error: e.to_s
175
+ log.debug_backtrace(e.backtrace)
176
176
  end
177
177
  end
178
178
 
@@ -12,43 +12,43 @@ module Fluent::Plugin
12
12
  MQTT_PORT = 1883
13
13
 
14
14
  desc 'The address to connect to.'
15
- config_param :host, :string, :default => '127.0.0.1'
15
+ config_param :host, :string, default: '127.0.0.1'
16
16
  desc 'The port to connect to.'
17
- config_param :port, :integer, :default => MQTT_PORT
17
+ config_param :port, :integer, default: MQTT_PORT
18
18
  desc 'MQTT keep alive interval.'
19
- config_param :keep_alive, :integer, :default => 15
19
+ config_param :keep_alive, :integer, default: 15
20
20
  desc 'Topic rewrite matching pattern.'
21
- config_param :topic_rewrite_pattern, :string, :default => nil
21
+ config_param :topic_rewrite_pattern, :string, default: nil
22
22
  desc 'Topic rewrite replacement string.'
23
- config_param :topic_rewrite_replacement, :string, :default => nil
23
+ config_param :topic_rewrite_replacement, :string, default: nil
24
24
  desc 'Initial retry interval.'
25
- config_param :initial_interval, :integer, :default => 1
25
+ config_param :initial_interval, :integer, default: 1
26
26
  desc 'Increasing ratio of retry interval.'
27
- config_param :retry_inc_ratio, :integer, :default => 2
27
+ config_param :retry_inc_ratio, :integer, default: 2
28
28
 
29
29
  config_section :security, required: false, multi: false do
30
30
  ### User based authentication
31
31
  desc 'The username for authentication'
32
- config_param :username, :string, :default => nil
32
+ config_param :username, :string, default: nil
33
33
  desc 'The password for authentication'
34
- config_param :password, :string, :default => nil
34
+ config_param :password, :string, default: nil
35
35
  desc 'Use TLS or not.'
36
- config_param :use_tls, :bool, :default => nil
36
+ config_param :use_tls, :bool, default: nil
37
37
  config_section :tls, required: false, multi: true do
38
38
  desc 'TLS ca file.'
39
- config_param :ca_file, :string, :default => nil
39
+ config_param :ca_file, :string, default: nil
40
40
  desc 'TLS key file.'
41
- config_param :key_file, :string, :default => nil
41
+ config_param :key_file, :string, default: nil
42
42
  desc 'TLS cert file.'
43
- config_param :cert_file, :string, :default => nil
43
+ config_param :cert_file, :string, default: nil
44
44
  end
45
45
  end
46
46
 
47
47
  config_section :monitor, required: false, multi: false do
48
48
  desc 'Recording send time for monitoring.'
49
- config_param :send_time, :bool, :default => false
49
+ config_param :send_time, :bool, default: false
50
50
  desc 'Recording key name of send time for monitoring.'
51
- config_param :send_time_key, :string, :default => "send_time"
51
+ config_param :send_time_key, :string, default: "send_time"
52
52
  end
53
53
 
54
54
  # This method is called before starting.
@@ -72,8 +72,8 @@ module Fluent::Plugin
72
72
  end
73
73
 
74
74
  def sleep_retry_interval(e, message)
75
- $log.error "#{message},#{e.class},#{e.message}"
76
- $log.error "Retry in #{@retry_interval} sec"
75
+ log.error "#{message},#{e.class},#{e.message}"
76
+ log.error "Retry in #{@retry_interval} sec"
77
77
  sleep @retry_interval
78
78
  increment_retry_interval
79
79
  end
@@ -95,7 +95,7 @@ module Fluent::Plugin
95
95
  def start
96
96
  super
97
97
 
98
- $log.debug "start to connect mqtt broker #{@host}:#{@port}"
98
+ log.debug "start to connect mqtt broker #{@host}:#{@port}"
99
99
  opts = {
100
100
  host: @host,
101
101
  port: @port,
@@ -182,7 +182,7 @@ module Fluent::Plugin
182
182
  def add_send_time(record)
183
183
  if @send_time
184
184
  # send_time is recorded in ms
185
- record.merge({@send_time_key => Fluent::EventTime.now})
185
+ record.merge({"#{@send_time_key}": Fluent::EventTime.now})
186
186
  else
187
187
  record
188
188
  end
@@ -192,7 +192,7 @@ module Fluent::Plugin
192
192
  if es.class == Fluent::OneEventStream
193
193
  es = inject_values_to_event_stream(tag, es)
194
194
  es.each do |time, record|
195
- $log.debug "#{rewrite_tag(tag)}, #{add_send_time(record)}"
195
+ log.debug "#{rewrite_tag(tag)}, #{add_send_time(record)}"
196
196
  publish_error_handler do
197
197
  @client.publish(rewrite_tag(tag), @formatter.format(tag, time, add_send_time(record)))
198
198
  end
@@ -201,14 +201,14 @@ module Fluent::Plugin
201
201
  es = inject_values_to_event_stream(tag, es)
202
202
  array = []
203
203
  es.each do |time, record|
204
- $log.debug "#{rewrite_tag(tag)}, #{add_send_time(record)}"
204
+ log.debug "#{rewrite_tag(tag)}, #{add_send_time(record)}"
205
205
  array << add_send_time(record)
206
206
  end
207
207
  publish_error_handler do
208
208
  @client.publish(rewrite_tag(tag), @formatter.format(tag, Fluent::EventTime.now, array))
209
209
  end
210
210
  end
211
- $log.flush
211
+ log.flush
212
212
  end
213
213
 
214
214
  def process(tag, es)
data/test/helper.rb CHANGED
@@ -1,26 +1,6 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
1
+ require 'bundler/setup'
10
2
  require 'test/unit'
11
3
 
12
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
5
+ $LOAD_PATH.unshift(__dir__)
14
6
  require 'fluent/test'
15
- unless ENV.has_key?('VERBOSE')
16
- nulllogger = Object.new
17
- nulllogger.instance_eval {|obj|
18
- def method_missing(method, *args)
19
- # pass
20
- end
21
- }
22
- $log = nulllogger
23
- end
24
-
25
- class Test::Unit::TestCase
26
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mqtt-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama