Class: Fasten::Task

Inherits:
Object
  • Object
show all
Includes:
Support::State
Defined in:
lib/fasten/task.rb

Instance Attribute Summary collapse

Attributes included from Support::State

#dif, #error, #fin, #ini, #runner, #state

Instance Method Summary collapse

Methods included from Support::State

#deps, #deps_str, #idle?, #last_avg, #last_err, #last_stat, #paused?, #pausing?, #quitting?, #running?

Constructor Details

#initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, weight: 1, worker_class: nil) ⇒ Task

Returns a new instance of Task.



10
11
12
13
14
15
16
17
18
19
# File 'lib/fasten/task.rb', line 10

def initialize(name:, shell: nil, ruby: nil, block: nil, request: nil, after: nil, weight: 1, worker_class: nil)
  self.name = name
  self.shell = shell
  self.ruby = ruby
  self.block = block
  self.request = request
  self.after = after
  self.weight = weight
  self.worker_class = worker_class
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



7
8
9
# File 'lib/fasten/task.rb', line 7

def after
  @after
end

#blockObject

Returns the value of attribute block.



8
9
10
# File 'lib/fasten/task.rb', line 8

def block
  @block
end

#dependantsObject

Returns the value of attribute dependants.



8
9
10
# File 'lib/fasten/task.rb', line 8

def dependants
  @dependants
end

#dependsObject

Returns the value of attribute depends.



8
9
10
# File 'lib/fasten/task.rb', line 8

def depends
  @depends
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/fasten/task.rb', line 7

def name
  @name
end

#requestObject

Returns the value of attribute request.



8
9
10
# File 'lib/fasten/task.rb', line 8

def request
  @request
end

#responseObject

Returns the value of attribute response.



8
9
10
# File 'lib/fasten/task.rb', line 8

def response
  @response
end

#rubyObject

Returns the value of attribute ruby.



7
8
9
# File 'lib/fasten/task.rb', line 7

def ruby
  @ruby
end

#run_scoreObject

Returns the value of attribute run_score.



8
9
10
# File 'lib/fasten/task.rb', line 8

def run_score
  @run_score
end

#shellObject

Returns the value of attribute shell.



7
8
9
# File 'lib/fasten/task.rb', line 7

def shell
  @shell
end

#weightObject

Returns the value of attribute weight.



8
9
10
# File 'lib/fasten/task.rb', line 8

def weight
  @weight
end

#workerObject

Returns the value of attribute worker.



8
9
10
# File 'lib/fasten/task.rb', line 8

def worker
  @worker
end

#worker_classObject

Returns the value of attribute worker_class.



7
8
9
# File 'lib/fasten/task.rb', line 7

def worker_class
  @worker_class
end

Instance Method Details

#kindObject



32
33
34
# File 'lib/fasten/task.rb', line 32

def kind
  'task'
end

#marshal_dumpObject



21
22
23
# File 'lib/fasten/task.rb', line 21

def marshal_dump
  [@name, @state, @ini, @fin, @dif, @request, @response, @shell, @ruby, @block&.object_id, @error]
end

#marshal_load(data) ⇒ Object



25
26
27
28
29
30
# File 'lib/fasten/task.rb', line 25

def marshal_load(data)
  @name, @state, @ini, @fin, @dif, @request, @response, @shell, @ruby, block_id, @error = data
  @block = ObjectSpace._id2ref block_id if block_id

  raise "Sorry, unable to get block for task #{self}, please try using threads" if block_id && !@block.is_a?(Proc)
end

#to_sObject



36
37
38
# File 'lib/fasten/task.rb', line 36

def to_s
  name
end