Class: Sqewer::Resubmit

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_to_resubmit, execute_after_timestamp) ⇒ Resubmit

Returns a new instance of Resubmit.



6
7
8
9
# File 'lib/sqewer/resubmit.rb', line 6

def initialize(job_to_resubmit, execute_after_timestamp)
  @job = job_to_resubmit
  @execute_after = execute_after_timestamp
end

Instance Attribute Details

#execute_afterObject (readonly)

Returns the value of attribute execute_after.



4
5
6
# File 'lib/sqewer/resubmit.rb', line 4

def execute_after
  @execute_after
end

#jobObject (readonly)

Returns the value of attribute job.



3
4
5
# File 'lib/sqewer/resubmit.rb', line 3

def job
  @job
end

Instance Method Details

#run(ctx) ⇒ Object



11
12
13
14
15
# File 'lib/sqewer/resubmit.rb', line 11

def run(ctx)
  # Take the maximum delay period SQS allows
  required_delay = (@execute_after - Time.now.to_i)
  ctx.submit!(@job, delay_seconds: required_delay)
end