Module: SolidQueue::Job::Executable
- Extended by:
- ActiveSupport::Concern
- Included in:
- SolidQueue::Job
- Defined in:
- lib/solid_queue_mongoid/models/job/executable.rb
Instance Method Summary collapse
- #discard ⇒ Object
- #dispatch ⇒ Object
-
#dispatch_bypassing_concurrency_limits ⇒ Object
Called by ClaimedExecution#release — bypasses the semaphore check.
- #execution ⇒ Object
- #finished! ⇒ Object (also: #finish)
- #finished? ⇒ Boolean
- #prepare_for_execution ⇒ Object
- #ready ⇒ Object
- #status ⇒ Object
Instance Method Details
#discard ⇒ Object
118 119 120 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 118 def discard execution&.discard end |
#dispatch ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 76 def dispatch if due? if acquire_concurrency_lock ready else handle_concurrency_conflict end else schedule end end |
#dispatch_bypassing_concurrency_limits ⇒ Object
Called by ClaimedExecution#release — bypasses the semaphore check.
89 90 91 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 89 def dispatch_bypassing_concurrency_limits ready end |
#execution ⇒ Object
135 136 137 138 139 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 135 def execution %w[ready claimed failed].reduce(nil) do |acc, status| acc || public_send("#{status}_execution") end end |
#finished! ⇒ Object Also known as: finish
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 93 def finished! if SolidQueue.preserve_finished_jobs? update(finished_at: Time.current) # Clean up the claimed execution if still present (e.g. called directly # outside of ClaimedExecution#finished which does its own destroy!). claimed_execution&.destroy else destroy! end end |
#finished? ⇒ Boolean
106 107 108 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 106 def finished? finished_at.present? end |
#prepare_for_execution ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 68 def prepare_for_execution if due? dispatch else schedule end end |
#ready ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 122 def ready existing = ReadyExecution.where(job_id: id).first return existing if existing re = ReadyExecution.new(job_id: id) re.queue_name = queue_name re.priority = priority re.save! re rescue Mongoid::Errors::Validations, Mongo::Error::OperationFailure ReadyExecution.where(job_id: id).first end |
#status ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/solid_queue_mongoid/models/job/executable.rb', line 110 def status if finished? :finished elsif (exec = execution) exec.type end end |