Class: LockTask

Inherits:
Object
  • Object
show all
Defined in:
app/services/lock_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution_type:) ⇒ LockTask

Returns a new instance of LockTask.



6
7
8
# File 'app/services/lock_task.rb', line 6

def initialize(execution_type:)
  @execution_type = execution_type
end

Instance Attribute Details

#execution_typeObject (readonly)

Returns the value of attribute execution_type.



4
5
6
# File 'app/services/lock_task.rb', line 4

def execution_type
  @execution_type
end

Instance Method Details

#any_pending?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/services/lock_task.rb', line 26

def any_pending?
  all_pending.any?
end

#performObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/lock_task.rb', line 10

def perform
  task = all_pending
         .find_one_and_update(
           {
             "$set" => { status: "starting" }
           }, return_document: :after
         )
  return unless task

  task.reload

  persist_metrics(task)

  task
end