fluent-plugin-mqtt-io 0.3.8 → 0.3.9

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: ea9384521f10b7caf8a29d7e1fc0e232e9a3a1c7
4
- data.tar.gz: 0f656339bd4d72eb7a9b4bb1c2303994a532b8e2
3
+ metadata.gz: 3782aca018e523e428d463853e6bab8419f005ca
4
+ data.tar.gz: bec45595691338a9c383bb41925d14bf8815b685
5
5
  SHA512:
6
- metadata.gz: 52eabe67a7a94c3dd93d9bdc831fd226cafb990eb3c37df4dd652fc73161c801231f4aa84036506597b20b4f7b0a9711b85325977df6b87e6f3d9c065298a3c6
7
- data.tar.gz: a7df1e0b1bd500eb83b7382249b12e3c48007713e4d3369e80eeb5214fa89931597e4db877dc7902c0325f6e8fedc4077551c916e5c36e470c6eab5875d22f93
6
+ metadata.gz: cfb2568422ebd1239ab1f50d59d9238fd0e8ccf71bd5bfe2e84487ac93580f9ab1990d64a519ae2751fd78bf7066e8258925656528e33fb79b910e2502c887af
7
+ data.tar.gz: 9eba2f2086abd8f94995248e032d76aae10fe5f3a3ca204a28a1d0e752288464aca0e08ebcf9525223b706aedfc3e73a47947a60ad38c4c265bc159a6699497c
data/README.md CHANGED
@@ -63,6 +63,7 @@ The default MQTT topic is "#". Configurable options are the following:
63
63
 
64
64
  - **host**: IP address of MQTT broker
65
65
  - **port**: Port number of MQTT broker
66
+ - **client_id**: Client ID that to connect to MQTT broker
66
67
  - **format** (mandatory): Input parser can be chosen, e.g. json, xml
67
68
  - In order to use xml format, you need to install [fluent-plugin-xml-parser](https://github.com/toyokazu/fluent-plugin-xml-parser).
68
69
  - Default time_key field for json format is 'time'
@@ -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.8"
7
+ spec.version = "0.3.9"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -10,6 +10,8 @@ module Fluent::Plugin
10
10
  base.config_param :host, :string, default: '127.0.0.1'
11
11
  base.desc 'The port to connect to.'
12
12
  base.config_param :port, :integer, default: MQTT_PORT
13
+ base.desc 'Client ID of MQTT Connection'
14
+ base.config_param :client_id, :string, default: nil
13
15
  base.desc 'Specify keep alive interval.'
14
16
  base.config_param :keep_alive, :integer, default: 15
15
17
  base.desc 'Specify initial connection retry interval.'
@@ -21,19 +23,19 @@ module Fluent::Plugin
21
23
 
22
24
  base.config_section :security, required: false, multi: false do
23
25
  ### User based authentication
24
- base.desc 'The username for authentication'
25
- base.config_param :username, :string, default: nil
26
- base.desc 'The password for authentication'
27
- base.config_param :password, :string, default: nil
28
- base.desc 'Use TLS or not.'
29
- base.config_param :use_tls, :bool, default: nil
30
- base.config_section :tls, required: false, multi: true do
31
- base.desc 'Specify TLS ca file.'
32
- base.config_param :ca_file, :string, default: nil
33
- base.desc 'Specify TLS key file.'
34
- base.config_param :key_file, :string, default: nil
35
- base.desc 'Specify TLS cert file.'
36
- base.config_param :cert_file, :string, default: nil
26
+ desc 'The username for authentication'
27
+ config_param :username, :string, default: nil
28
+ desc 'The password for authentication'
29
+ config_param :password, :string, default: nil
30
+ desc 'Use TLS or not.'
31
+ config_param :use_tls, :bool, default: nil
32
+ config_section :tls, required: false, multi: false do
33
+ desc 'Specify TLS ca file.'
34
+ config_param :ca_file, :string, default: nil
35
+ desc 'Specify TLS key file.'
36
+ config_param :key_file, :string, default: nil
37
+ desc 'Specify TLS cert file.'
38
+ config_param :cert_file, :string, default: nil
37
39
  end
38
40
  end
39
41
  end
@@ -51,11 +53,12 @@ module Fluent::Plugin
51
53
  opts = {
52
54
  host: @host,
53
55
  port: @port,
56
+ client_id: @client_id,
54
57
  keep_alive: @keep_alive
55
58
  }
56
- opts[:username] = @security.username if @security.respond_to?(:username)
57
- opts[:password] = @security.password if @security.respond_to?(:password)
58
- if @security.respond_to?(:use_tls) && @security.use_tls
59
+ opts[:username] = @security.username if @security.to_h.has_key?(:username)
60
+ opts[:password] = @security.password if @security.to_h.has_key?(:password)
61
+ if @security.to_h.has_key?(:use_tls) && @security.use_tls
59
62
  opts[:ssl] = @security.use_tls
60
63
  opts[:ca_file] = @security.tls.ca_file
61
64
  opts[:cert_file] = @security.tls.cert_file
@@ -12,6 +12,7 @@ module Fluent::Plugin
12
12
 
13
13
  helpers :compat_parameters, :formatter, :inject
14
14
 
15
+
15
16
  desc 'Topic rewrite matching pattern.'
16
17
  config_param :topic_rewrite_pattern, :string, default: nil
17
18
  desc 'Topic rewrite replacement string.'
@@ -11,7 +11,7 @@ class MqttInputTest < Test::Unit::TestCase
11
11
  CONFIG = %[
12
12
  ]
13
13
 
14
- def create_driver(conf = CONFIG, opts = {})
14
+ def create_driver(conf = CONFIG, opts = {})
15
15
  Fluent::Test::Driver::Input.new(Fluent::Plugin::MqttInput, opts: opts).configure(conf)
16
16
  end
17
17
 
@@ -20,13 +20,30 @@ class MqttInputTest < Test::Unit::TestCase
20
20
  d = create_driver %[
21
21
  host 127.0.0.1
22
22
  port 1300
23
+ client_id aa-bb-cc-dd
23
24
  <parse>
24
25
  @type json
25
26
  time_format %FT%T%:z
26
27
  </parse>
28
+ <security>
29
+ use_tls true
30
+ <tls>
31
+ ca_file /cert/cacert.pem
32
+ key_file /cert/private.key
33
+ cert_file /cert/cert.pem
34
+ </tls>
35
+ </security>
36
+
27
37
  ]
28
38
  assert_equal '127.0.0.1', d.instance.host
29
39
  assert_equal 1300, d.instance.port
40
+ assert_equal 'aa-bb-cc-dd', d.instance.client_id
41
+
42
+ assert_equal true, d.instance.security.use_tls
43
+ assert_equal '/cert/cacert.pem', d.instance.security.tls.ca_file
44
+ assert_equal '/cert/private.key', d.instance.security.tls.key_file
45
+ assert_equal '/cert/cert.pem', d.instance.security.tls.cert_file
46
+
30
47
  end
31
48
  end
32
49
  end
@@ -11,7 +11,7 @@ class MqttOutputTest < Test::Unit::TestCase
11
11
  CONFIG = %[
12
12
  ]
13
13
 
14
- def create_driver(conf = CONFIG, opts = {})
14
+ def create_driver(conf = CONFIG, opts = {})
15
15
  Fluent::Test::Driver::Output.new(Fluent::Plugin::MqttOutput, opts: opts).configure(conf)
16
16
  end
17
17
 
@@ -20,12 +20,31 @@ class MqttOutputTest < Test::Unit::TestCase
20
20
  d = create_driver %[
21
21
  host 127.0.0.1
22
22
  port 1300
23
+ client_id aa-bb-cc-dd
23
24
  <format>
24
25
  @type json
25
26
  </format>
27
+ <monitor>
28
+ send_time true
29
+ </monitor>
30
+ <security>
31
+ use_tls true
32
+ <tls>
33
+ ca_file /cert/cacert.pem
34
+ key_file /cert/private.key
35
+ cert_file /cert/cert.pem
36
+ </tls>
37
+ </security>
26
38
  ]
27
39
  assert_equal '127.0.0.1', d.instance.host
28
40
  assert_equal 1300, d.instance.port
29
- end
41
+ assert_equal true, d.instance.monitor.send_time
42
+ assert_equal 'aa-bb-cc-dd', d.instance.client_id
43
+
44
+ assert_equal true, d.instance.security.use_tls
45
+ assert_equal '/cert/cacert.pem', d.instance.security.tls.ca_file
46
+ assert_equal '/cert/private.key', d.instance.security.tls.key_file
47
+ assert_equal '/cert/cert.pem', d.instance.security.tls.cert_file
48
+ end
30
49
  end
31
50
  end
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.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
8
8
  autorequire:
9
9
  bindir: []
10
10
  cert_chain: []
11
- date: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd