Sha256: b6f023f2a000e5f3f2eb9792f9d80dd39e452901af9a0b32a33016d672f1aa6c

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

class ProconBypassMan::FetchAndRunRemotePbmActionJob < ProconBypassMan::BaseJob
  extend ProconBypassMan::HasExternalApiSetting

  def self.perform
    pbm_jobs = ProconBypassMan::HttpClient.new(path: path, server_pool: server_pool).get
    if pbm_jobs.nil? || pbm_jobs.size.zero?
      # ProconBypassMan.logger.debug "remote pbm_jobsはありませんでした"
      return
    else
      pbm_job_hash = pbm_jobs.first
      begin
        pbm_job_object = ProconBypassMan::RemotePbmActionObject.new(action: pbm_job_hash["action"],
                                                                    status: pbm_job_hash["status"],
                                                                    uuid: pbm_job_hash["uuid"],
                                                                    created_at: pbm_job_hash["created_at"],
                                                                    job_args: pbm_job_hash["args"])
        pbm_job_object.validate!
        ProconBypassMan::RunRemotePbmActionDispatchCommand.execute(action: pbm_job_object.action, uuid: pbm_job_object.uuid, job_args: pbm_job_object.job_args)
      rescue ProconBypassMan::RemotePbmActionObject::ValidationError => e
        ProconBypassMan::SendErrorCommand.execute(error: e)
      end
    end
  end

  def self.path
    device_id = ProconBypassMan.device_id
    "/api/devices/#{device_id}/pbm_jobs"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
procon_bypass_man-0.1.15 lib/procon_bypass_man/background/jobs/fetch_and_run_remote_pbm_action_job.rb
procon_bypass_man-0.1.14 lib/procon_bypass_man/background/jobs/fetch_and_run_remote_pbm_action_job.rb