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(db: :default, lock_key:, result:) ⇒ LockedExcutionResult

Returns a new instance of LockedExcutionResult.



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

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

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



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

def db
  @db
end

#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



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

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

#success?Boolean

Returns:

  • (Boolean)


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

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