Class: ActiveJobStatus::JobTracker

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

Constant Summary collapse

DEFAULT_EXPIRATION =
72.hours.freeze

Instance Method Summary collapse

Constructor Details

#initialize(job_id:, store: ActiveJobStatus.store, expiration: ActiveJobStatus.expiration) ⇒ JobTracker

Returns a new instance of JobTracker.



5
6
7
8
9
# File 'lib/active_job_status/job_tracker.rb', line 5

def initialize(job_id:, store: ActiveJobStatus.store, expiration: ActiveJobStatus.expiration)
  @job_id = job_id
  @store = store
  @expiration = expiration
end

Instance Method Details

#completedObject



26
27
28
29
30
31
# File 'lib/active_job_status/job_tracker.rb', line 26

def completed
  store.write(
    job_id,
    JobStatus::COMPLETED.to_s
  )
end

#deletedObject



33
34
35
# File 'lib/active_job_status/job_tracker.rb', line 33

def deleted
  store.delete(job_id)
end

#enqueuedObject



11
12
13
14
15
16
17
# File 'lib/active_job_status/job_tracker.rb', line 11

def enqueued
  store.write(
    job_id,
    JobStatus::ENQUEUED.to_s,
    expires_in: expiration || DEFAULT_EXPIRATION
  )
end

#performingObject



19
20
21
22
23
24
# File 'lib/active_job_status/job_tracker.rb', line 19

def performing
  store.write(
    job_id,
    JobStatus::WORKING.to_s
  )
end