Sha256: 4abb5e1b3e65a978b667c422fb4b1f8b230e545c585ff21e9c211202b5912af2

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

module ActiveJob::QueueAdapters::SolidQueueExt::Workers
  def exposes_workers?
    true
  end

  def fetch_workers(workers_relation)
    solid_queue_processes_from_workers_relation(workers_relation).collect do |process|
      worker_from_solid_queue_process(process)
    end
  end

  def count_workers(workers_relation)
    solid_queue_processes_from_workers_relation(workers_relation).count
  end

  def find_worker(worker_id)
    if process = SolidQueue::Process.find_by(id: worker_id)
      worker_attributes_from_solid_queue_process(process)
    end
  end

  private
    def solid_queue_processes_from_workers_relation(relation)
      SolidQueue::Process.where(kind: "Worker").offset(relation.offset_value).limit(relation.limit_value)
    end

    def worker_from_solid_queue_process(process)
      MissionControl::Jobs::Worker.new(queue_adapter: self, **worker_attributes_from_solid_queue_process(process))
    end

    def worker_attributes_from_solid_queue_process(process)
      {
        id: process.id,
        name: "PID: #{process.pid}",
        hostname: process.hostname,
        last_heartbeat_at: process.last_heartbeat_at,
        configuration: process.metadata,
        raw_data: process.as_json
      }
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mission_control-jobs-0.6.0 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.5.0 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.4.0 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.3.3 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.3.2 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.3.1 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.3.0 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.2.2 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.2.1 lib/active_job/queue_adapters/solid_queue_ext/workers.rb
mission_control-jobs-0.2.0 lib/active_job/queue_adapters/solid_queue_ext/workers.rb