Class: Taskinator::Task::SubProcess

Inherits:
Taskinator::Task show all
Defined in:
lib/taskinator/task.rb

Overview

a task which delegates to another process

Instance Attribute Summary collapse

Attributes inherited from Taskinator::Task

#created_at, #definition, #next, #options, #process, #queue, #updated_at, #uuid

Instance Method Summary collapse

Methods inherited from Taskinator::Task

#<=>, #cancel!, #cancelled?, #complete!, define_job_task, define_step_task, define_sub_process_task, #enqueue!, #fail!, #paused?, #start!, #to_s

Methods included from Instrumentation

#cancelled_payload, #completed_payload, #enqueued_payload, #failed_payload, #instrument, #paused_payload, #processing_payload, #resumed_payload

Methods included from Persistence

add_process_to_list, deserialize, included, processes_list_key, serialize

Methods included from Workflow

#current_state, #current_state=, #transition

Constructor Details

#initialize(process, sub_process, options = {}) ⇒ SubProcess

NOTE: also wraps sequential and concurrent processes

Raises:

  • (ArgumentError)


269
270
271
272
273
274
275
# File 'lib/taskinator/task.rb', line 269

def initialize(process, sub_process, options={})
  super(process, options)
  raise ArgumentError, 'sub_process' if sub_process.nil? || !sub_process.is_a?(Process)

  @sub_process = sub_process
  @sub_process.parent = self
end

Instance Attribute Details

#sub_processObject (readonly)

Returns the value of attribute sub_process.



265
266
267
# File 'lib/taskinator/task.rb', line 265

def sub_process
  @sub_process
end

Instance Method Details

#accept(visitor) ⇒ Object



297
298
299
300
# File 'lib/taskinator/task.rb', line 297

def accept(visitor)
  super
  visitor.visit_process(:sub_process)
end

#enqueueObject



277
278
279
# File 'lib/taskinator/task.rb', line 277

def enqueue
  sub_process.enqueue!
end

#incr_count?Boolean

Returns:

  • (Boolean)


291
292
293
294
295
# File 'lib/taskinator/task.rb', line 291

def incr_count?
  # subprocess tasks aren't included in the total count of tasks
  # since they simply delegate to the tasks of the respective subprocess definition
  false
end

#inspectObject



302
303
304
# File 'lib/taskinator/task.rb', line 302

def inspect
  %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} uuid="#{uuid}", definition=:#{definition}, sub_process=#{sub_process.inspect}, current_state=:#{current_state}>)
end

#startObject



281
282
283
284
285
286
287
288
289
# File 'lib/taskinator/task.rb', line 281

def start
  sub_process.start!

rescue => e
  Taskinator.logger.error(e)
  Taskinator.logger.debug(e.backtrace)
  fail!(e)
  raise e
end