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.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Attributes inherited from Taskinator::Task
#created_at, #definition, #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.
166 167 168 169 170 171 172 173 174 |
# File 'lib/taskinator/task.rb', line 166 def initialize(process, method, args, ={}) super(process, ) 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.
164 165 166 |
# File 'lib/taskinator/task.rb', line 164 def args @args end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
163 164 165 |
# File 'lib/taskinator/task.rb', line 163 def method @method end |
Instance Method Details
#accept(visitor) ⇒ Object
192 193 194 195 196 |
# File 'lib/taskinator/task.rb', line 192 def accept(visitor) super visitor.visit_attribute(:method) visitor.visit_args(:args) end |
#enqueue ⇒ Object
176 177 178 |
# File 'lib/taskinator/task.rb', line 176 def enqueue Taskinator.queue.enqueue_task(self) end |
#executor ⇒ Object
198 199 200 |
# File 'lib/taskinator/task.rb', line 198 def executor @executor ||= Taskinator::Executor.new(definition, self) end |
#inspect ⇒ Object
202 203 204 |
# File 'lib/taskinator/task.rb', line 202 def inspect %(#<#{self.class.name}:0x#{self.__id__.to_s(16)} uuid="#{uuid}", definition=:#{definition}, method=:#{method}, args=#{args}, current_state=:#{current_state}>) end |
#start ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/taskinator/task.rb', line 180 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 |