lib/fluent/plugin/mqtt_output_mixin.rb in fluent-plugin-mqtt-io-0.1.2 vs lib/fluent/plugin/mqtt_output_mixin.rb in fluent-plugin-mqtt-io-0.2.0
- old
+ new
@@ -1,13 +1,13 @@
module Fluent
module MqttOutputMixin
# config_param defines a parameter. You can refer a parameter via @path instance variable
# Without :default, a parameter is required.
-
+
def self.included(base)
base.config_param :port, :integer, :default => 1883
- base.config_param :bind, :string, :default => '127.0.0.1'
+ base.config_param :host, :string, :default => '127.0.0.1'
base.config_param :username, :string, :default => nil
base.config_param :password, :string, :default => nil
base.config_param :keep_alive, :integer, :default => 15
base.config_param :ssl, :bool, :default => nil
base.config_param :ca_file, :string, :default => nil
@@ -27,11 +27,11 @@
# If the configuration is invalid, raise Fluent::ConfigError.
def configure(conf)
super
# You can also refer raw parameter via conf[name].
- @bind ||= conf['bind']
+ @host ||= conf['host']
@port ||= conf['port']
@username ||= conf['username']
@password ||= conf['password']
@keep_alive ||= conf['keep_alive']
@time_key ||= conf['time_key']
@@ -61,13 +61,13 @@
# This method is called when starting.
# Open sockets or files here.
def start
super
- $log.debug "start mqtt #{@bind}"
+ $log.debug "start mqtt #{@host}"
opts = {
- host: @bind,
+ host: @host,
port: @port,
username: @username,
password: @password,
keep_alive: @keep_alive
}
@@ -139,16 +139,16 @@
else
tag.gsub("\.", "/").gsub(Regexp.new(@topic_rewrite_pattern), @topic_rewrite_replacement)
end
end
- def json_parse message
+ def json_parse(message)
begin
y = Yajl::Parser.new
y.parse(message)
rescue
$log.error "JSON parse error", :error => $!.to_s, :error_class => $!.class.to_s
- $log.warn_backtrace $!.backtrace
+ $log.warn_backtrace $!.backtrace
end
end
end
end