Class: RoundhouseUi::Backends::SolidQueue::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/roundhouse_ui/backends/solid_queue.rb

Overview

Wraps a Solid Queue execution + its job in the SortedEntry-like interface the views expect (klass / jid / args / item / at / queue / retry / delete).

Instance Method Summary collapse

Constructor Details

#initialize(execution) ⇒ Entry

Returns a new instance of Entry.



128
129
130
131
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 128

def initialize(execution)
  @execution = execution
  @job = execution.job
end

Instance Method Details

#argsObject



136
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 136

def args  = active_job_args

#atObject



137
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 137

def at    = @execution.try(:scheduled_at) || @execution.try(:created_at)

#deleteObject

discard removes the job row along with the execution and takes the row lock while it does; destroy drops only the execution, leaving an orphaned solid_queue_jobs row that nothing will ever pick up again.



160
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 160

def delete = @execution.respond_to?(:discard) ? @execution.discard : @execution.destroy

#itemObject



139
140
141
142
143
144
145
146
147
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 139

def item
  err = (@execution.respond_to?(:error) && @execution.error) || {}
  {
    "class" => klass, "args" => args, "queue" => queue,
    "error_class"     => err["exception_class"],
    "error_message"   => err["message"],
    "error_backtrace" => err["backtrace"]
  }
end

#jidObject



133
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 133

def jid   = @execution.job_id.to_s

#klassObject



134
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 134

def klass = @job&.class_name

#queueObject



135
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 135

def queue = @job&.queue_name

#retryObject

Guarded at CALL time. As a trailing if on an endless def this was evaluated when the class body loaded, against a nil class-level ivar — so the method was never defined and every Retry raised NoMethodError.

Raises:

  • (NotImplementedError)


152
153
154
155
156
# File 'lib/roundhouse_ui/backends/solid_queue.rb', line 152

def retry
  raise NotImplementedError, "this entry cannot be retried" unless @execution.respond_to?(:retry)

  @execution.retry
end