Skip to content

Commit

Permalink
Merge pull request #36 from fractaledmind/verification-job
Browse files Browse the repository at this point in the history
Add a verification job
  • Loading branch information
fractaledmind authored Aug 22, 2024
2 parents 10677a1 + 87c9bd1 commit ff5926a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: .
specs:
litestream (0.10.5)
activejob
logfmt (>= 0.0.10)
sqlite3

Expand Down
13 changes: 13 additions & 0 deletions app/jobs/litestream/verification_job.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions lib/litestream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def initialize

mattr_writer :username
mattr_writer :password
mattr_writer :queue

class << self
def verify!(database_path)
Expand Down Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions litestream.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ff5926a

Please sign in to comment.