class OnlineMigrations::ConstantLockRetrier

‘LockRetrier` implementation that has a constant delay between tries and lock timeout for each try

@example

# This will attempt 5 retries with 2 seconds between each unsuccessful try
# and 50ms set as lock timeout for each try:
config.retrier = OnlineMigrations::ConstantLockRetrier.new(attempts: 5, delay: 2.seconds, lock_timeout: 0.05.seconds)

Attributes

attempts[R]

LockRetrier API implementation

@return [Integer] Number of retrying attempts @see LockRetrier#attempts

Public Class Methods

new(attempts:, delay:, lock_timeout:) click to toggle source

Create a new ConstantLockRetrier instance

@param attempts [Integer] Maximum number of attempts @param delay [Numeric] Sleep time after unsuccessful lock attempt (in seconds) @param lock_timeout [Numeric] Database lock timeout value (in seconds)

Calls superclass method
# File lib/online_migrations/lock_retrier.rb, line 153
def initialize(attempts:, delay:, lock_timeout:)
  super()
  @attempts = attempts
  @delay = delay
  @lock_timeout = lock_timeout
end

Public Instance Methods

delay(_attempt) click to toggle source

LockRetrier API implementation

@return [Numeric] Sleep time after unsuccessful lock attempt (in seconds) @see LockRetrier#delay

# File lib/online_migrations/lock_retrier.rb, line 174
def delay(_attempt)
  @delay
end
lock_timeout(_attempt) click to toggle source

LockRetrier API implementation

@return [Numeric] Database lock timeout value (in seconds) @see LockRetrier#lock_timeout

# File lib/online_migrations/lock_retrier.rb, line 165
def lock_timeout(_attempt)
  @lock_timeout
end