Class: Stockpile::LockedExcutionResult

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

Overview

Stockpile::LockedExcutionResult

Wrapper containing result of locked execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lock_key:, result:) ⇒ LockedExcutionResult

Returns a new instance of LockedExcutionResult.



24
25
26
27
# File 'lib/stockpile/locked_execution_result.rb', line 24

def initialize(lock_key:, result:)
  @lock_key = lock_key
  @result = result
end

Instance Attribute Details

#lock_keyObject (readonly)

Returns the value of attribute lock_key.



22
23
24
# File 'lib/stockpile/locked_execution_result.rb', line 22

def lock_key
  @lock_key
end

#resultObject (readonly)

Returns the value of attribute result.



22
23
24
# File 'lib/stockpile/locked_execution_result.rb', line 22

def result
  @result
end

Instance Method Details

#release_lockObject



29
30
31
# File 'lib/stockpile/locked_execution_result.rb', line 29

def release_lock
  Stockpile.redis { |r| r.expire(lock_key, 0) }
end

#success?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/stockpile/locked_execution_result.rb', line 33

def success?
  !result.is_a?(Stockpile::FailedLockExecution)
end