Class: PartitionGardener::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/partition_gardener/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/partition_gardener/configuration.rb', line 19

def initialize
  @notifier = ->(_message_or_error, context: {}) {}
  @connection_resolver = method(:default_connection_resolver)
  @statement_timeout_wrapper = ->(_timeout, &block) { block.call }
  @today_resolver = -> { Date.today }
  @schema_name = "public"
  @continue_on_error = true
  @advisory_lock_mode = :transaction
  @analyze_after_rebalance = false
  @incremental_rebalance = true
  @run_record_enabled = true
  @run_record_store = nil
  @retention_detach_concurrently = false
  @strict_maintenance_backend_validation = false
  @current_run_metrics = nil
end

Instance Attribute Details

#advisory_lock_modeObject

Returns the value of attribute advisory_lock_mode.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def advisory_lock_mode
  @advisory_lock_mode
end

#analyze_after_rebalanceObject

Returns the value of attribute analyze_after_rebalance.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def analyze_after_rebalance
  @analyze_after_rebalance
end

#connection_resolverObject

Returns the value of attribute connection_resolver.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def connection_resolver
  @connection_resolver
end

#continue_on_errorObject

Returns the value of attribute continue_on_error.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def continue_on_error
  @continue_on_error
end

#current_run_metricsObject

Returns the value of attribute current_run_metrics.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def current_run_metrics
  @current_run_metrics
end

#incremental_rebalanceObject

Returns the value of attribute incremental_rebalance.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def incremental_rebalance
  @incremental_rebalance
end

#notifierObject

Returns the value of attribute notifier.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def notifier
  @notifier
end

#retention_detach_concurrentlyObject

Returns the value of attribute retention_detach_concurrently.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def retention_detach_concurrently
  @retention_detach_concurrently
end

#run_record_enabledObject

Returns the value of attribute run_record_enabled.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def run_record_enabled
  @run_record_enabled
end

#run_record_storeObject



36
37
38
# File 'lib/partition_gardener/configuration.rb', line 36

def run_record_store
  @run_record_store ||= default_run_record_store
end

#schema_nameObject

Returns the value of attribute schema_name.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def schema_name
  @schema_name
end

#statement_timeout_wrapperObject

Returns the value of attribute statement_timeout_wrapper.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def statement_timeout_wrapper
  @statement_timeout_wrapper
end

#strict_maintenance_backend_validationObject

Returns the value of attribute strict_maintenance_backend_validation.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def strict_maintenance_backend_validation
  @strict_maintenance_backend_validation
end

#today_resolverObject

Returns the value of attribute today_resolver.



3
4
5
# File 'lib/partition_gardener/configuration.rb', line 3

def today_resolver
  @today_resolver
end

Instance Method Details

#connectionObject

Raises:

  • (ArgumentError)


40
41
42
43
44
45
# File 'lib/partition_gardener/configuration.rb', line 40

def connection
  resolved = @connection_resolver.call
  raise ArgumentError, "PartitionGardener connection is not configured" unless resolved

  resolved
end

#notify(message_or_error, context: {}) ⇒ Object



47
48
49
# File 'lib/partition_gardener/configuration.rb', line 47

def notify(message_or_error, context: {})
  @notifier.call(message_or_error, context: context)
end

#todayObject



55
56
57
# File 'lib/partition_gardener/configuration.rb', line 55

def today
  @today_resolver.call
end

#with_statement_timeout(timeout, &block) ⇒ Object



51
52
53
# File 'lib/partition_gardener/configuration.rb', line 51

def with_statement_timeout(timeout, &block)
  @statement_timeout_wrapper.call(timeout, &block)
end