Class: SafePgMigrations::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/safe-pg-migrations/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/safe-pg-migrations/configuration.rb', line 20

def initialize
  self.backfill_batch_size = 100_000
  self.backfill_pause = 0.5.second
  self.blocking_activity_logger_margin = 1.second
  self.blocking_activity_logger_verbose = true
  self.default_value_backfill_threshold = nil
  self.increase_lock_timeout_on_retry = false
  self.lock_timeout = nil
  self.max_lock_timeout_for_retry = 1.second
  self.max_tries = 5
  self.retry_delay = 1.minute
  self.safe_timeout = 5.seconds
  self.sensitive_logger = nil
end

Instance Attribute Details

#lock_timeoutObject

Returns the value of attribute lock_timeout.



18
19
20
# File 'lib/safe-pg-migrations/configuration.rb', line 18

def lock_timeout
  @lock_timeout
end

#max_lock_timeout_for_retryObject

Returns the value of attribute max_lock_timeout_for_retry.



18
19
20
# File 'lib/safe-pg-migrations/configuration.rb', line 18

def max_lock_timeout_for_retry
  @max_lock_timeout_for_retry
end

#safe_timeoutObject

Returns the value of attribute safe_timeout.



18
19
20
# File 'lib/safe-pg-migrations/configuration.rb', line 18

def safe_timeout
  @safe_timeout
end

Instance Method Details

#pg_lock_timeoutObject



72
73
74
75
76
77
78
79
# File 'lib/safe-pg-migrations/configuration.rb', line 72

def pg_lock_timeout
  return pg_duration lock_timeout if lock_timeout

  # if statement timeout and lock timeout have the same value, statement timeout will raise in priority. We actually
  # need the opposite for BlockingActivityLogger to detect lock timeouts correctly.
  # By reducing the lock timeout by a very small margin, we ensure that the lock timeout is raised in priority
  pg_duration safe_timeout * 0.99
end

#pg_statement_timeoutObject



68
69
70
# File 'lib/safe-pg-migrations/configuration.rb', line 68

def pg_statement_timeout
  pg_duration safe_timeout
end