Class: Conflow::Job

Inherits:
Redis::Field show all
Includes:
Redis::Identifier, Redis::Model
Defined in:
lib/conflow/job.rb

Overview

Represents conflow job.

Instance Attribute Summary collapse

Attributes included from Redis::Identifier

#id

Attributes inherited from Redis::Field

#key

Instance Method Summary collapse

Methods included from Redis::Identifier

included

Methods included from Redis::Model

#==, #destroy!, included

Constructor Details

#initializeJob

Returns instance of Job. It sets status to 0 (pending) for new jobs



25
26
27
28
# File 'lib/conflow/job.rb', line 25

def initialize(*)
  super
  status.default(0)
end

Instance Attribute Details

#class_nameString

Returns class name of the worker class.

Returns:

  • (String)

    class name of the worker class



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/conflow/job.rb', line 14

class Job < Conflow::Redis::Field
  include Conflow::Redis::Model
  include Conflow::Redis::Identifier

  has_many :successors, Conflow::Job
  field :params,     :hash
  field :class_name, :value
  field :status,     :value # 0 - pending, 1 - finished
  field :hook,       :value

  # Returns instance of Job. It sets status to 0 (pending) for new jobs
  def initialize(*)
    super
    status.default(0)
  end

  # Convienience method returning Class object of the job.
  # It's the class supplied in {Conflow::Flow#run} method
  # @return [Class] class of the job
  def worker_type
    Object.const_get(class_name.to_s)
  end
end

#hookString?

Returns name of the method on related flow to be called once job is finished.

Returns:

  • (String, nil)

    name of the method on related flow to be called once job is finished



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/conflow/job.rb', line 14

class Job < Conflow::Redis::Field
  include Conflow::Redis::Model
  include Conflow::Redis::Identifier

  has_many :successors, Conflow::Job
  field :params,     :hash
  field :class_name, :value
  field :status,     :value # 0 - pending, 1 - finished
  field :hook,       :value

  # Returns instance of Job. It sets status to 0 (pending) for new jobs
  def initialize(*)
    super
    status.default(0)
  end

  # Convienience method returning Class object of the job.
  # It's the class supplied in {Conflow::Flow#run} method
  # @return [Class] class of the job
  def worker_type
    Object.const_get(class_name.to_s)
  end
end

#paramsHash?

Returns parameters needed to complete job.

Returns:

  • (Hash, nil)

    parameters needed to complete job



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/conflow/job.rb', line 14

class Job < Conflow::Redis::Field
  include Conflow::Redis::Model
  include Conflow::Redis::Identifier

  has_many :successors, Conflow::Job
  field :params,     :hash
  field :class_name, :value
  field :status,     :value # 0 - pending, 1 - finished
  field :hook,       :value

  # Returns instance of Job. It sets status to 0 (pending) for new jobs
  def initialize(*)
    super
    status.default(0)
  end

  # Convienience method returning Class object of the job.
  # It's the class supplied in {Conflow::Flow#run} method
  # @return [Class] class of the job
  def worker_type
    Object.const_get(class_name.to_s)
  end
end

#statusInteger

Status of the job

Returns:

  • (Integer)

    0 - pending, 1 - finished



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/conflow/job.rb', line 14

class Job < Conflow::Redis::Field
  include Conflow::Redis::Model
  include Conflow::Redis::Identifier

  has_many :successors, Conflow::Job
  field :params,     :hash
  field :class_name, :value
  field :status,     :value # 0 - pending, 1 - finished
  field :hook,       :value

  # Returns instance of Job. It sets status to 0 (pending) for new jobs
  def initialize(*)
    super
    status.default(0)
  end

  # Convienience method returning Class object of the job.
  # It's the class supplied in {Conflow::Flow#run} method
  # @return [Class] class of the job
  def worker_type
    Object.const_get(class_name.to_s)
  end
end

Instance Method Details

#worker_typeClass

Convienience method returning Class object of the job. It’s the class supplied in Flow#run method

Returns:

  • (Class)

    class of the job



33
34
35
# File 'lib/conflow/job.rb', line 33

def worker_type
  Object.const_get(class_name.to_s)
end