Skip to content

Commit

Permalink
Merge pull request #41 from G5/rails_7
Browse files Browse the repository at this point in the history
rails 7 upgrade
  • Loading branch information
Matt-Bishop authored Oct 14, 2024
2 parents 100d357 + c20b7e4 commit ee3c2b7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.12.3]
### Changed
- Rails 7 friendliness

## [0.12.2]
### Changed
- Remove validation for job server url for destruction of a job
Expand Down
39 changes: 18 additions & 21 deletions app/workers/asyncapi/client/job_cleaner_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,26 @@ def perform(job_id)
private

def destroy_remote(job)
# Typhoeus needs a server_job_url to destroy a job, but if a job for whatever reason does not have one
# it will never be destroyed and the sidekiq queue will just fill up and keep retrying
return unless url_ok_for?(job) #TO DO getting a lot of errors from jobs with no server_job_url so we need to figure out how those invalid jobs are getting created
errors = validate_remote_job_info(job)
if errors.empty?
response = Typhoeus.delete(job.server_job_url, {
params: { secret: job.secret },
headers: job.headers,
})

raise response.body unless response.success?
else
raise log_remote_error_for(job, errors)
end
# if the job is invalid- we don't care, just destroy the invalid job
return unless url_ok_for?(job) && headers_ok_for?(job) && job.secret.present?

response = Typhoeus.delete(job.server_job_url, {
params: { secret: job.secret },
headers: job.headers,
})

raise response.body unless response.success?
end

def validate_remote_job_info(job)
errors = []
errors << "server_job_url is invalid" unless url_ok_for?(job)
errors << "authorization headers are not present" unless headers_ok_for?(job)
errors << "secret is not present" unless job.secret.present?
errors
end
# stopping raising errors if the job is invalid- we don't care, just destroy the invalid job

# def validate_remote_job_info(job)
# errors = []
# errors << "server_job_url is invalid" unless url_ok_for?(job)
# errors << "authorization headers are not present" unless headers_ok_for?(job)
# errors << "secret is not present" unless job.secret.present?
# errors
# end

def url_ok_for?(job)
uri = URI.parse(job.server_job_url)
Expand Down
4 changes: 2 additions & 2 deletions asyncapi-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Gem::Specification.new do |s|

s.files = Dir["{app,config,db,lib,spec/factories}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

s.add_dependency "rails", "~> 6.0"
s.add_dependency "rails", "> 6"
s.add_dependency "sidekiq"
s.add_dependency "sidekiq-cron"
s.add_dependency "kaminari"
s.add_dependency "api-pagination"
s.add_dependency "typhoeus"
s.add_dependency "aasm", ">= 4.0"
s.add_dependency "ar_after_transaction"
s.add_dependency "sprockets", "<4"
s.add_dependency "sprockets-rails"

s.add_development_dependency "sqlite3", '~> 1.4.2'
s.add_development_dependency "rspec-rails"
Expand Down
2 changes: 1 addition & 1 deletion lib/asyncapi/client/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Asyncapi
module Client
VERSION = "0.12.2".freeze
VERSION = "0.12.3".freeze
end
end
12 changes: 6 additions & 6 deletions spec/workers/job_cleaner_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ module Client
})
end

it 'raise the error' do
expect { described_class.new.perform(job.id) }.to raise_error(/Not enough info to delete expired remote job: secret is not present/)
end
# it 'raise the error' do
# expect { described_class.new.perform(job.id) }.to raise_error(/Not enough info to delete expired remote job: secret is not present/)
# end
end

context 'when the job is missing the authorization headers' do
Expand All @@ -78,9 +78,9 @@ module Client
})
end

it 'raise with the error' do
expect { described_class.new.perform(job.id) }.to raise_error(/Not enough info to delete expired remote job: authorization headers are not present/)
end
# it 'raise with the error' do
# expect { described_class.new.perform(job.id) }.to raise_error(/Not enough info to delete expired remote job: authorization headers are not present/)
# end
end
end

Expand Down

0 comments on commit ee3c2b7

Please sign in to comment.