fluent-plugin-mqtt-io 0.4.1 → 0.4.2

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: 910f2e9e505f0b9ae26ac26f29357a849b2e11df
4
- data.tar.gz: ede83bec8dac5beda12524e0ba2d939460c664da
3
+ metadata.gz: 57a1a03befc225ac307f35c2ad9d5043c5be180b
4
+ data.tar.gz: 1b457000a1bfefa873c1e6fa7e576f0fc3a35870
5
5
  SHA512:
6
- metadata.gz: 8f40b5f402574cf81877f0bfd70a9d9331f724e0b3b667b9404f9d71e4cf732c3321200b219f1922e9cae835543f2a8c2cec55c3e2b33018f376e5277a09773d
7
- data.tar.gz: 81e7227607e0ed5d95fc33b4e4015a5c1e323813a6c8604259cbcf578a74b7c7f89879d872e0e39d86062031c8c67540edcef84be8a2d4808f4f99e2d0255f24
6
+ metadata.gz: 80d14876fb728ca4ec6ff0df74454cbba3d46d992fd13673b7f169eefca0b96e3b53c854a46cdc44f768c465134d01569441b4f964efaeb3ac1018993533c937
7
+ data.tar.gz: 53fbdc544df75db543d8bdab4d5c8e49257efc991f97ffdf215e9ada7e032f3ee108884642f20a71f834dc35f37ee3ade264eec4eea7a0102e3c4fc2657cb787
data/README.md CHANGED
@@ -64,7 +64,7 @@ The default MQTT topic is "#". Configurable options are the following:
64
64
  - **host**: IP address of MQTT broker
65
65
  - **port**: Port number of MQTT broker
66
66
  - **client_id**: Client ID that to connect to MQTT broker
67
- - **parser**: Parser plugin can be specified ![Parser Plugin](https://docs.fluentd.org/v1.0/articles/parser-plugin-overview)
67
+ - **parser**: Parser plugin can be specified [Parser Plugin](https://docs.fluentd.org/v1.0/articles/parser-plugin-overview)
68
68
  - **topic**: Topic name to be subscribed
69
69
  - **security**
70
70
  - **username**: User name for authentication
@@ -109,13 +109,13 @@ The options are basically the same as Input Plugin except for "parser (for Input
109
109
  If this option is omitted, timestamp field is not appended to the output record.
110
110
  - **topic_rewrite_pattern**: Regexp pattern to extract replacement words from received topic or tag name
111
111
  - **topic_rewrite_replacement**: Topic name used for the publish using extracted pattern
112
- - **format**: Formatter plugin can be specified. ![Formatter Plugin](https://docs.fluentd.org/v1.0/articles/formatter-plugin-overview)
112
+ - **format**: Formatter plugin can be specified. [Formatter Plugin](https://docs.fluentd.org/v1.0/articles/formatter-plugin-overview)
113
113
  - **monitor**: monitor section. only for fluent-plugin-mqtt-io
114
114
  - **send_time**: Add send time to message in millisecond (ms) as integer for debug and performance/delay analysis. only for fluent-plugin-mqtt-io
115
115
  - **send_time_key**: An attribute of send_time. only for fluent-plugin-mqtt-io
116
116
  - **time_type**: Type of time format (string (default), unixtime, float) only for fluent-plugin-mqtt-io
117
117
  - **time_format**: Time format e.g. %FT%T.%N%:z (refer strftime) only for fluent-plugin-mqtt-io
118
- - **buffer**: synchronous/asynchronous buffer is supported. Refer ![Buffer section configurations](https://docs.fluentd.org/v1.0/articles/buffer-section) for detailed configuration.
118
+ - **buffer**: synchronous/asynchronous buffer is supported. Refer [Buffer section configurations](https://docs.fluentd.org/v1.0/articles/buffer-section) for detailed configuration.
119
119
  - **async**: Enable asynchronous buffer transfer. Default is false.
120
120
 
121
121
  If you use different source, e.g. the other MQTT broker, log file and so on, there is no need to specifie topic rewriting. Skip the following descriptions.
@@ -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.4.1"
7
+ spec.version = "0.4.2"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -40,8 +40,7 @@ module Fluent::Plugin
40
40
  end
41
41
  end
42
42
 
43
- class MqttProxyError
44
- end
43
+ class MqttError < StandardError; end
45
44
 
46
45
  def current_plugin_name
47
46
  # should be implemented
@@ -84,12 +83,15 @@ module Fluent::Plugin
84
83
  end
85
84
 
86
85
  def retry_connect(e, message)
87
- log.error "#{message},#{e.class},#{e.message}"
88
- log.error "Retry in #{@retry_interval} sec"
89
- timer_execute("#{current_plugin_name}_connect".to_sym, @retry_interval, repeat: false, &method(:connect))
90
- increment_retry_interval
91
- after_disconnection
92
- @client.disconnect if @client.connected?
86
+ if !@_retrying
87
+ log.error "#{message},#{e.class},#{e.message}"
88
+ log.error "Retry in #{@retry_interval} sec"
89
+ timer_execute("#{current_plugin_name}_connect".to_sym, @retry_interval, repeat: false, &method(:connect))
90
+ @_retrying = true
91
+ increment_retry_interval
92
+ after_disconnection
93
+ @client.disconnect if @client.connected?
94
+ end
93
95
  end
94
96
 
95
97
  def kill_connect_thread
@@ -102,25 +104,37 @@ module Fluent::Plugin
102
104
  end
103
105
 
104
106
  def rescue_disconnection
107
+ # Errors cannot be caught by fluentd core must be caught here.
108
+ # Since fluentd core retries write method for buffered output
109
+ # when it caught Errors during the previous write,
110
+ # caughtable Error, e.g. MqttError, should be raised here.
105
111
  begin
106
112
  yield
107
113
  rescue MQTT::ProtocolException => e
108
114
  # TODO:
109
- # Currently MQTT::ProtocolException cannot be caught during @client.get
110
- # and @client.publish. The reason must be investigated...
111
- retry_connect(e, "Protocol error occurs.")
115
+ # Thread created via fluentd thread API, e.g. thread_create,
116
+ # cannot catch MQTT::ProtocolException raised from @read_thread
117
+ # in ruby-mqtt. So, the current version uses plugin local thread
118
+ # @connect_thread to catch it.
119
+ retry_connect(e, "Protocol error occurs in #{current_plugin_name}.")
120
+ raise MqttError, "Protocol error occurs."
112
121
  rescue Timeout::Error => e
113
- retry_connect(e, "Timeout error occurs.")
122
+ retry_connect(e, "Timeout error occurs in #{current_plugin_name}.")
123
+ raise Timeout::Error, "Timeout error occurs."
114
124
  rescue SystemCallError => e
115
- retry_connect(e, "System call error occurs.")
125
+ retry_connect(e, "System call error occurs in #{current_plugin_name}.")
126
+ raise SystemCallError, "System call error occurs."
116
127
  rescue StandardError=> e
117
- retry_connect(e, "The other error occurs.")
128
+ retry_connect(e, "The other error occurs in #{current_plugin_name}.")
129
+ raise StandardError, "The other error occurs."
118
130
  rescue MQTT::NotConnectedException=> e
119
131
  # Since MQTT::NotConnectedException is raised only on publish,
120
132
  # connection error should be catched before this error.
121
133
  # So, reconnection process is omitted for this Exception
122
134
  # to prevent waistful increment of retry interval.
123
- log.error "MQTT not connected exception occurs.,#{e.class},#{e.message}"
135
+ #log.error "MQTT not connected exception occurs.,#{e.class},#{e.message}"
136
+ #retry_connect(e, "MQTT not connected exception occurs.")
137
+ raise MqttError, "MQTT not connected exception occurs in #{current_plugin_name}."
124
138
  end
125
139
  end
126
140
 
@@ -132,6 +146,7 @@ module Fluent::Plugin
132
146
 
133
147
  def connect
134
148
  #@connect_thread = thread_create("#{current_plugin_name}_monitor".to_sym) do
149
+ @_retrying = false
135
150
  @connect_thread = Thread.new do
136
151
  rescue_disconnection do
137
152
  @client.connect
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mqtt-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
8
8
  autorequire:
9
9
  bindir: []
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2018-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.6.13
131
+ rubygems_version: 2.6.14.1
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: fluentd input/output plugin for mqtt broker