Class: KueRuby::KueJob

Inherits:
Object
  • Object
show all
Defined in:
lib/kue_ruby.rb

Overview

Job record from Automattic Kue redis store

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKueJob

Returns a new instance of KueJob.



74
75
76
77
# File 'lib/kue_ruby.rb', line 74

def initialize
  self.delay = 0
  super()
end

Instance Attribute Details

#backoffObject

Returns the value of attribute backoff.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def backoff
  @backoff
end

#created_atObject

Returns the value of attribute created_at.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def created_at
  @created_at
end

#dataObject

Returns the value of attribute data.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def data
  @data
end

#delayObject

Returns the value of attribute delay.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def delay
  @delay
end

#idObject

Returns the value of attribute id.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def id
  @id
end

#max_attemptsObject

Returns the value of attribute max_attempts.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def max_attempts
  @max_attempts
end

#priorityObject

Returns the value of attribute priority.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def priority
  @priority
end

#promote_atObject

Returns the value of attribute promote_at.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def promote_at
  @promote_at
end

#stateObject

Returns the value of attribute state.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def state
  @state
end

#typeObject

Returns the value of attribute type.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def type
  @type
end

#updated_atObject

Returns the value of attribute updated_at.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def updated_at
  @updated_at
end

#zidObject

Returns the value of attribute zid.



70
71
72
# File 'lib/kue_ruby.rb', line 70

def zid
  @zid
end

Instance Method Details

#save(kue) ⇒ KueJob

Save job data to redis kue

Parameters:

  • KueRuby

    KueRuby instance with redis connection

Returns:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/kue_ruby.rb', line 84

def save(kue)
  kue.redis.hmset(
    "#{kue.prefix}:job:#{id}",
    'max_attempts',   max_attempts.to_i,
    'backoff',        backoff.to_json,
    'type',           type,
    'created_at',     (created_at.to_f * 1000).to_i,
    'updated_at',     (Time.now.to_f * 1000).to_i,
    'promote_at',     (Time.now.to_f * 1000).to_i + delay,
    'priority',       priority.to_i,
    'data',           data.to_json,
    'state',          state
  )
  self
end