Class: LockSlot

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution_type:, node: nil) ⇒ LockSlot

Returns a new instance of LockSlot.



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

def initialize(execution_type:, node: nil)
  @execution_type = execution_type
  @node = node
end

Instance Attribute Details

#execution_typeObject (readonly)

Returns the value of attribute execution_type.



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

def execution_type
  @execution_type
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

Instance Method Details

#performObject



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

def perform
  return unless selected_node

  selected_node
    .slots
    .available
    .where(execution_type: execution_type)
    .find_one_and_update(
      {
        "$set" => {
          status: "attaching"
        }
      },
      return_document: :after
    )
end