lib/fluent/plugin/out_sakuraio.rb in fluent-plugin-sakuraio-0.1.3 vs lib/fluent/plugin/out_sakuraio.rb in fluent-plugin-sakuraio-0.2.0
- old
+ new
@@ -10,10 +10,11 @@
config_param :url, :string, secret: true
config_param :modules, :array, value_type: :string, secret: true
# channels {"channel_number": ["key", "type"]}
config_param :channels, :hash
+ config_param :ping, :integer, default: 60
def configure(conf)
super
ensure_reactor_running
@@ -27,11 +28,13 @@
EM.run
end
end
def run
- @client = Faye::WebSocket::Client.new(@url)
+ options = {}
+ @ping.positive? options[:ping] = @ping
+ @client = Faye::WebSocket::Client.new(@url, nil, options)
EM.next_tick do
@client.on :open do
log.info "sakuraio: starting websocket connection for #{@url}."
end
@@ -41,11 +44,12 @@
@client.on :error do |event|
log.warn "sakuraio: #{event.message}"
end
- @client.on :close do
- @client = nil
+ @client.on :close do |event|
+ log.warn "sakuraio: #{event.code} #{event.reason}"
+ run
end
end
end
def process(_tag, events)