Class: Taskinator::Task::Step
- Inherits:
-
Taskinator::Task
- Object
- Taskinator::Task
- Taskinator::Task::Step
- Defined in:
- lib/taskinator/task.rb
Overview
a task which invokes the specified method on the definition 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.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Attributes inherited from Taskinator::Task
#created_at, #next, #options, #process, #queue, #updated_at, #uuid
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #enqueue ⇒ Object
- #executor ⇒ Object
-
#initialize(process, method, args, options = {}) ⇒ Step
constructor
A new instance of Step.
- #inspect ⇒ Object
- #start ⇒ Object
Methods inherited from Taskinator::Task
#<=>, #cancel!, #cancelled?, #complete!, define_job_task, define_step_task, define_sub_process_task, #enqueue!, #fail!, #incr_count?, #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, method, args, options = {}) ⇒ Step
Returns a new instance of Step.
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/taskinator/task.rb', line 162 def initialize(process, method, args, ={}) super(process, ) @definition = process.definition # for convenience raise ArgumentError, 'method' if method.nil? raise NoMethodError, method unless executor.respond_to?(method) @method = method @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
160 161 162 |
# File 'lib/taskinator/task.rb', line 160 def args @args end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
158 159 160 |
# File 'lib/taskinator/task.rb', line 158 def definition @definition end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
159 160 161 |
# File 'lib/taskinator/task.rb', line 159 def method @method end |
Instance Method Details
#accept(visitor) ⇒ Object
189 190 191 192 193 194 |
# File 'lib/taskinator/task.rb', line 189 def accept(visitor) super visitor.visit_type(:definition) visitor.visit_attribute(:method) visitor.visit_args(:args) end |
#enqueue ⇒ Object
173 174 175 |
# File 'lib/taskinator/task.rb', line 173 def enqueue Taskinator.queue.enqueue_task(self) end |
#executor ⇒ Object
196 197 198 |
# File 'lib/taskinator/task.rb', line 196 def executor @executor ||= Taskinator::Executor.new(@definition, self) end |
#inspect ⇒ Object
200 201 202 |
# File 'lib/taskinator/task.rb', line 200 def inspect %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} uuid="#{uuid}", method=:#{method}, args=#{args}, current_state=:#{current_state}>) end |
#start ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/taskinator/task.rb', line 177 def start executor.send(method, *args) # ASSUMPTION: when the method returns, the task is considered to be complete complete! rescue => e Taskinator.logger.error(e) Taskinator.logger.debug(e.backtrace) fail!(e) raise e end |