Class: SimpleFormsApi::FormRemediation::UploadRetryJob
- Inherits:
-
Object
- Object
- SimpleFormsApi::FormRemediation::UploadRetryJob
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.simple_forms_api.upload_retry_job'
Instance Attribute Summary collapse
-
#config ⇒ Object
private
Returns the value of attribute config.
-
#directory ⇒ Object
private
Returns the value of attribute directory.
-
#file ⇒ Object
private
Returns the value of attribute file.
Instance Method Summary collapse
- #perform(file, directory, config) ⇒ Object
- #retry_later(delay: 30.minutes.from_now) ⇒ Object private
- #service_available?(region) ⇒ Boolean private
Instance Attribute Details
#config ⇒ Object (private)
Returns the value of attribute config.
39 40 41 |
# File 'app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb', line 39 def config @config end |
#directory ⇒ Object (private)
Returns the value of attribute directory.
39 40 41 |
# File 'app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb', line 39 def directory @directory end |
#file ⇒ Object (private)
Returns the value of attribute file.
39 40 41 |
# File 'app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb', line 39 def file @file end |
Instance Method Details
#perform(file, directory, config) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb', line 20 def perform(file, directory, config) @file = file @directory = directory @config = config uploader = config.uploader_class.new(directory:, config:) begin StatsD.increment("#{STATSD_KEY_PREFIX}.total") uploader.store!(file) rescue Aws::S3::Errors::ServiceError raise if service_available?(config.s3_settings.region) retry_later end end |
#retry_later(delay: 30.minutes.from_now) ⇒ Object (private)
48 49 50 51 |
# File 'app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb', line 48 def retry_later(delay: 30.minutes.from_now) Rails.logger.info("S3 service unavailable. Retrying upload later for #{file.filename}.") self.class.perform_in(delay, file, directory, config) end |
#service_available?(region) ⇒ Boolean (private)
41 42 43 44 45 46 |
# File 'app/sidekiq/simple_forms_api/form_remediation/upload_retry_job.rb', line 41 def service_available?(region) Aws::S3::Client.new(region:).list_buckets true rescue Aws::S3::Errors::ServiceError false end |