Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/logstash/inputs/sqlite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require "logstash/inputs/base"
require "logstash/namespace"
require "socket"
require "stud/interval"
require "concurrent"


# Read rows from an sqlite database.
Expand Down Expand Up @@ -146,7 +148,7 @@ def run(queue)

begin
@logger.debug("Tailing sqlite db", :path => @path)
loop do
until stop?
count = 0
@table_data.each do |k, table|
table_name = table[:name]
Expand Down Expand Up @@ -174,7 +176,8 @@ def run(queue)
# sleep a bit
@logger.debug("No new rows. Sleeping.", :time => sleeptime)
sleeptime = [sleeptime * 2, sleep_max].min
sleep(sleeptime)

Stud.stoppable_sleep(sleeptime) { stop? }
else
sleeptime = sleep_min
end
Expand Down
1 change: 1 addition & 0 deletions logstash-input-sqlite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'jdbc-sqlite3'

s.add_development_dependency 'logstash-devutils'
s.add_development_dependency 'logstash-codec-plain'
end

10 changes: 10 additions & 0 deletions spec/inputs/sqlite_spec.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing

# encoding: utf-8 
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks!

require "logstash/inputs/sqlite"
require "logstash/codecs/plain"

describe LogStash::Inputs::Sqlite do
describe "stopping" do
let(:config) { {"path" => "testdb.sqlite3"} }
it_behaves_like "an interruptible input plugin"
end
end