Class: Taskinator::Task::Job
- Inherits:
-
Taskinator::Task
- Object
- Taskinator::Task
- Taskinator::Task::Job
- Defined in:
- lib/taskinator/task.rb
Overview
a task which invokes the specified background job the args must be intrinsic types, since they are serialized to YAML
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Attributes inherited from Taskinator::Task
#next, #options, #process, #queue, #uuid
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#can_complete_task? ⇒ Boolean
NOTE: this _does not_ work when checking out-of-process.
- #enqueue ⇒ Object
-
#initialize(process, job, args, options = {}) ⇒ Job
constructor
A new instance of Job.
- #perform ⇒ Object
Methods inherited from Taskinator::Task
#<=>, base_key, #cancelled?, define_job_task, define_step_task, define_sub_process_task, #on_completed_entry, #on_failed_entry, #paused?, #reload, #to_s
Methods included from Persistence
add_process_to_list, deserialize, included, list_key, serialize
Constructor Details
#initialize(process, job, args, options = {}) ⇒ Job
Returns a new instance of Job.
178 179 180 181 182 183 184 185 186 187 |
# File 'lib/taskinator/task.rb', line 178 def initialize(process, job, args, ={}) super(process, ) @definition = process.definition # for convenience raise ArgumentError, 'job' if job.nil? raise ArgumentError, 'job' unless job.methods.include?(:perform) || job.instance_methods.include?(:perform) @job = job @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
176 177 178 |
# File 'lib/taskinator/task.rb', line 176 def args @args end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
174 175 176 |
# File 'lib/taskinator/task.rb', line 174 def definition @definition end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
175 176 177 |
# File 'lib/taskinator/task.rb', line 175 def job @job end |
Instance Method Details
#accept(visitor) ⇒ Object
205 206 207 208 209 210 |
# File 'lib/taskinator/task.rb', line 205 def accept(visitor) super visitor.visit_type(:definition) visitor.visit_type(:job) visitor.visit_args(:args) end |
#can_complete_task? ⇒ Boolean
NOTE: this _does not_ work when checking out-of-process
201 202 203 |
# File 'lib/taskinator/task.rb', line 201 def can_complete_task? defined?(@is_complete) && @is_complete end |
#enqueue ⇒ Object
189 190 191 |
# File 'lib/taskinator/task.rb', line 189 def enqueue Taskinator.queue.enqueue_job(self) end |
#perform ⇒ Object
193 194 195 196 197 198 |
# File 'lib/taskinator/task.rb', line 193 def perform Taskinator.instrumenter.instrument(:execute_job_task, :uuid => uuid) do yield(job, args) end @is_complete = true end |