fluent-plugin-mqtt-io 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de59247eae560befc4d28b446d68e3e9ef650e90
4
- data.tar.gz: 6e9eb9e006557bdad477407ec7d648bacf73d9ce
3
+ metadata.gz: 37e8d6d8654a36f64c79820fbad23be5ae0ddebb
4
+ data.tar.gz: e9948422c7a870dcc6fae0d823ffb11c7c57015e
5
5
  SHA512:
6
- metadata.gz: f96037a4572be86d1acf889569d41f814dfc13270eda73dbb7b704c2de05e8ad83723c3648d90e1f530a443ea52bd189f88e861982ed376e67d320964fef5afd
7
- data.tar.gz: 18a41fef17638a172e500df27aa51b45da20e3ef022823893f358d26ed581bdae5d86af4e1bb0568ffb2054da1fc108051123b93d4010b46980f31905ff552a3
6
+ metadata.gz: 374d8bdcd8ac17ef363f68808211948071d8b8eaedb9e0c0d93ad878a44d358793b9ae95512bcf1ed64bf1acb421fb70740428c39ca66127383b9aad09a2bb45
7
+ data.tar.gz: 2b0d5bddcf1184ffeeb1f630cd0c1caf5688d37b17187dd320d9104d03aa2b998b047dc5c1a1e45378d334120f327ea323e15a515c55536b5540a4e4c9bfa42d
@@ -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.3"
7
+ spec.version = "0.3.4"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -9,7 +9,7 @@ module Fluent::Plugin
9
9
 
10
10
  Fluent::Plugin.register_input('mqtt', self)
11
11
 
12
- helpers :thread, :compat_parameters, :parser
12
+ helpers :compat_parameters, :parser
13
13
 
14
14
  desc 'The topic to subscribe.'
15
15
  config_param :topic, :string, default: '#'
@@ -59,14 +59,13 @@ module Fluent::Plugin
59
59
  def after_connection
60
60
  if @client.connected?
61
61
  @client.subscribe(@topic)
62
- thread_create(:in_mqtt_get) do
63
- rescue_disconnection do
64
- @client.get do |topic, message|
65
- emit(topic, message)
66
- end
62
+ @get_thread = thread_create(:in_mqtt_get) do
63
+ @client.get do |topic, message|
64
+ emit(topic, message)
67
65
  end
68
66
  end
69
67
  end
68
+ @get_thread
70
69
  end
71
70
 
72
71
  def add_recv_time(record)
@@ -4,7 +4,7 @@ module Fluent::Plugin
4
4
  MQTT_PORT = 1883
5
5
 
6
6
  def self.included(base)
7
- base.helpers :timer
7
+ base.helpers :timer, :thread
8
8
 
9
9
  base.desc 'The address to connect to.'
10
10
  base.config_param :host, :string, default: '127.0.0.1'
@@ -63,7 +63,6 @@ module Fluent::Plugin
63
63
  end
64
64
 
65
65
  init_retry_interval
66
- @client_mutex = Mutex.new
67
66
  @client = MQTT::Client.new(opts)
68
67
  connect
69
68
  end
@@ -113,17 +112,20 @@ module Fluent::Plugin
113
112
 
114
113
  def after_connection
115
114
  # should be implemented
115
+ # returns thread instance for monitor thread to wait
116
+ # for Exception raised by MQTT I/O
116
117
  end
117
118
 
118
119
  def connect
119
- @client_mutex.lock
120
- rescue_disconnection do
121
- @client.connect
122
- log.debug "connected to mqtt broker #{@host}:#{@port} for #{current_plugin_name}"
123
- init_retry_interval
120
+ thread_create("#{current_plugin_name}_monitor".to_sym) do
121
+ rescue_disconnection do
122
+ @client.connect
123
+ log.debug "connected to mqtt broker #{@host}:#{@port} for #{current_plugin_name}"
124
+ init_retry_interval
125
+ thread = after_connection
126
+ thread.join
127
+ end
124
128
  end
125
- @client_mutex.unlock
126
- after_connection
127
129
  end
128
130
  end
129
131
  end
@@ -60,6 +60,13 @@ module Fluent::Plugin
60
60
  super
61
61
  end
62
62
 
63
+ def after_connection
64
+ @dummy_thread = thread_create(:out_mqtt_dummy) do
65
+ Thread.stop
66
+ end
67
+ @dummy_thread
68
+ end
69
+
63
70
  def current_plugin_name
64
71
  :out_mqtt
65
72
  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.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama