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, #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)


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

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.



267
268
269
# File 'lib/taskinator/task.rb', line 267

def sub_process
  @sub_process
end

Instance Method Details

#accept(visitor) ⇒ Object



299
300
301
302
# File 'lib/taskinator/task.rb', line 299

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

#enqueueObject



279
280
281
# File 'lib/taskinator/task.rb', line 279

def enqueue
  sub_process.enqueue!
end

#incr_count?Boolean

Returns:

  • (Boolean)


293
294
295
296
297
# File 'lib/taskinator/task.rb', line 293

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



304
305
306
# File 'lib/taskinator/task.rb', line 304

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

#startObject



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

def start
  sub_process.start!

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