Class: Plines::EnqueuedJob

Inherits:
Struct
  • Object
show all
Includes:
RedisObjectsHelpers
Defined in:
lib/plines/enqueued_job.rb

Overview

Once a Plines::Job has been enqueued as a Qless job into redis, an EnqueuedJob is used to represent and hold the additional state that Plines needs to track about the job.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RedisObjectsHelpers

#declared_redis_object_keys, included, #key_prefix, #new_redis_object

Constructor Details

#initialize(qless, pipeline, jid, &block) ⇒ EnqueuedJob

Returns a new instance of EnqueuedJob.



12
13
14
15
16
17
# File 'lib/plines/enqueued_job.rb', line 12

def initialize(qless, pipeline, jid, &block)
  @qless = qless
  @redis = qless.redis
  super(pipeline, jid)
  instance_eval(&block) if block
end

Instance Attribute Details

#jidObject Also known as: id

Returns the value of attribute jid

Returns:

  • (Object)

    the current value of jid



7
8
9
# File 'lib/plines/enqueued_job.rb', line 7

def jid
  @jid
end

#pipelineObject

Returns the value of attribute pipeline

Returns:

  • (Object)

    the current value of pipeline



7
8
9
# File 'lib/plines/enqueued_job.rb', line 7

def pipeline
  @pipeline
end

#qlessObject (readonly)

Returns the value of attribute qless.



10
11
12
# File 'lib/plines/enqueued_job.rb', line 10

def qless
  @qless
end

#redisObject (readonly)

Returns the value of attribute redis.



10
11
12
# File 'lib/plines/enqueued_job.rb', line 10

def redis
  @redis
end

Class Method Details

.create(qless, pipeline, jid, *external_dependencies) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/plines/enqueued_job.rb', line 19

def self.create(qless, pipeline, jid, *external_dependencies)
  new(qless, pipeline, jid) do
    external_dependencies.each do |dep|
      pending_ext_deps << dep
    end
  end
end

Instance Method Details

#all_external_dependenciesObject



43
44
45
46
47
# File 'lib/plines/enqueued_job.rb', line 43

def all_external_dependencies
  pending_ext_deps.union(
    resolved_ext_deps, timed_out_ext_deps
  )
end

#pending_external_dependenciesObject



31
32
33
# File 'lib/plines/enqueued_job.rb', line 31

def pending_external_dependencies
  pending_ext_deps.members
end

#qless_jobObject



27
28
29
# File 'lib/plines/enqueued_job.rb', line 27

def qless_job
  qless.jobs[jid]
end

#resolve_external_dependency(name) ⇒ Object



53
54
55
56
# File 'lib/plines/enqueued_job.rb', line 53

def resolve_external_dependency(name)
  update_external_dependency \
    name, resolved_ext_deps, pending_ext_deps, timed_out_ext_deps
end

#resolved_external_dependenciesObject



35
36
37
# File 'lib/plines/enqueued_job.rb', line 35

def resolved_external_dependencies
  resolved_ext_deps.members
end

#timed_out_external_dependenciesObject



39
40
41
# File 'lib/plines/enqueued_job.rb', line 39

def timed_out_external_dependencies
  timed_out_ext_deps.members
end

#timeout_external_dependency(name) ⇒ Object



58
59
60
61
# File 'lib/plines/enqueued_job.rb', line 58

def timeout_external_dependency(name)
  update_external_dependency \
    name, timed_out_ext_deps, pending_ext_deps
end

#unresolved_external_dependenciesObject



49
50
51
# File 'lib/plines/enqueued_job.rb', line 49

def unresolved_external_dependencies
  pending_ext_deps.union(timed_out_ext_deps)
end