diff --git a/Gemfile.lock b/Gemfile.lock index 15b2922..abe3471 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,6 +2,7 @@ PATH remote: . specs: litestream (0.10.5) + activejob logfmt (>= 0.0.10) sqlite3 diff --git a/app/jobs/litestream/verification_job.rb b/app/jobs/litestream/verification_job.rb new file mode 100644 index 0000000..2b32142 --- /dev/null +++ b/app/jobs/litestream/verification_job.rb @@ -0,0 +1,13 @@ +require "active_job" + +module Litestream + class VerificationJob < ActiveJob::Base + queue_as Litestream.queue + + def perform + Litestream::Commands.databases.each do |db_hash| + Litestream.verify!(db_hash["path"]) + end + end + end +end diff --git a/lib/litestream.rb b/lib/litestream.rb index 8f0dceb..fc703b3 100644 --- a/lib/litestream.rb +++ b/lib/litestream.rb @@ -23,6 +23,7 @@ def initialize mattr_writer :username mattr_writer :password + mattr_writer :queue class << self def verify!(database_path) @@ -60,6 +61,10 @@ def password @password ||= ENV["LITESTREAM_PASSWORD"] || @@password end + def queue + @queue ||= ENV["LITESTREAM_QUEUE"] || @@queue || "default" + end + def replicate_process info = {} if !`which systemctl`.empty? diff --git a/litestream.gemspec b/litestream.gemspec index 9001153..ff0f291 100644 --- a/litestream.gemspec +++ b/litestream.gemspec @@ -27,6 +27,7 @@ Gem::Specification.new do |spec| # Uncomment to register a new dependency of your gem spec.add_dependency "logfmt", ">= 0.0.10" spec.add_dependency "sqlite3" + spec.add_dependency "activejob" spec.add_development_dependency "rubyzip" spec.add_development_dependency "rails" spec.add_development_dependency "sqlite3"