Sha256: f710962bd6c058ffae47a11e9fef71134a39e16018cd50d56d30be095106ec04

Contents?: true

Size: 520 Bytes

Versions: 1

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

module ExternalServices
  class ApiJob < ActiveJob::Base
    queue_as :default

    retry_on ExternalServices::Api::Error, attempts: 5, wait: ->(executions) { (Math.gamma(executions) * 60).seconds } # (n-1)! * 60

    def action_class
      "ExternalServices::ApiActions::#{self.class.to_s.demodulize.gsub(/ApiJob/, '')}".constantize
    end

    def perform(action_id)
      action = action_class.find(action_id)
      return if action.processed?

      action.execute!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
external_services-0.5.4 app/jobs/external_services/api_job.rb