Class: PoolLint::Configuration
- Inherits:
-
Object
- Object
- PoolLint::Configuration
- Defined in:
- lib/poollint/configuration.rb
Constant Summary collapse
- INSPECTION_POINTS =
%i[checkout checkin].freeze
- MODES =
%i[log raise].freeze
Instance Attribute Summary collapse
-
#allowed_settings ⇒ Object
Returns the value of attribute allowed_settings.
-
#check_advisory_locks ⇒ Object
Returns the value of attribute check_advisory_locks.
-
#check_probability ⇒ Object
Returns the value of attribute check_probability.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#ignore_if ⇒ Object
Returns the value of attribute ignore_if.
-
#inspection_point ⇒ Object
Returns the value of attribute inspection_point.
-
#inspection_timeout ⇒ Object
Returns the value of attribute inspection_timeout.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#mysql_watched_settings ⇒ Object
Returns the value of attribute mysql_watched_settings.
-
#rebaseline_after_report ⇒ Object
Returns the value of attribute rebaseline_after_report.
-
#suspicion_log_size ⇒ Object
Returns the value of attribute suspicion_log_size.
-
#track_custom_gucs ⇒ Object
Returns the value of attribute track_custom_gucs.
-
#watched_settings ⇒ Object
Returns the value of attribute watched_settings.
Instance Method Summary collapse
-
#initialize(environment: nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #inspection_timeout_ms ⇒ Object
- #inspection_timeout_ms=(value) ⇒ Object
- #suspicion_limit ⇒ Object
- #suspicion_limit=(value) ⇒ Object
- #test_environment? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(environment: nil) ⇒ Configuration
Returns a new instance of Configuration.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/poollint/configuration.rb', line 41 def initialize(environment: nil) @environment = environment || default_environment test_environment = @environment.to_s == "test" @allowed_settings = [] @check_advisory_locks = true @check_probability = 1.0 @ignore_if = nil @inspection_point = test_environment ? :checkin : :checkout @inspection_timeout = 0.25 @logger = nil @mode = test_environment ? :raise : :log @mysql_watched_settings = DEFAULT_MYSQL_SETTINGS.dup @rebaseline_after_report = true @suspicion_log_size = 20 @track_custom_gucs = true @watched_settings = DEFAULT_PG_SETTINGS.dup end |
Instance Attribute Details
#allowed_settings ⇒ Object
Returns the value of attribute allowed_settings.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def allowed_settings @allowed_settings end |
#check_advisory_locks ⇒ Object
Returns the value of attribute check_advisory_locks.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def check_advisory_locks @check_advisory_locks end |
#check_probability ⇒ Object
Returns the value of attribute check_probability.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def check_probability @check_probability end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
26 27 28 |
# File 'lib/poollint/configuration.rb', line 26 def environment @environment end |
#ignore_if ⇒ Object
Returns the value of attribute ignore_if.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def ignore_if @ignore_if end |
#inspection_point ⇒ Object
Returns the value of attribute inspection_point.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def inspection_point @inspection_point end |
#inspection_timeout ⇒ Object
Returns the value of attribute inspection_timeout.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def inspection_timeout @inspection_timeout end |
#logger ⇒ Object
Returns the value of attribute logger.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def logger @logger end |
#mode ⇒ Object
Returns the value of attribute mode.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def mode @mode end |
#mysql_watched_settings ⇒ Object
Returns the value of attribute mysql_watched_settings.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def mysql_watched_settings @mysql_watched_settings end |
#rebaseline_after_report ⇒ Object
Returns the value of attribute rebaseline_after_report.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def rebaseline_after_report @rebaseline_after_report end |
#suspicion_log_size ⇒ Object
Returns the value of attribute suspicion_log_size.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def suspicion_log_size @suspicion_log_size end |
#track_custom_gucs ⇒ Object
Returns the value of attribute track_custom_gucs.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def track_custom_gucs @track_custom_gucs end |
#watched_settings ⇒ Object
Returns the value of attribute watched_settings.
27 28 29 |
# File 'lib/poollint/configuration.rb', line 27 def watched_settings @watched_settings end |
Instance Method Details
#inspection_timeout_ms ⇒ Object
59 60 61 |
# File 'lib/poollint/configuration.rb', line 59 def inspection_timeout_ms (inspection_timeout * 1000).round end |
#inspection_timeout_ms=(value) ⇒ Object
63 64 65 |
# File 'lib/poollint/configuration.rb', line 63 def inspection_timeout_ms=(value) self.inspection_timeout = Float(value) / 1000 end |
#suspicion_limit ⇒ Object
67 68 69 |
# File 'lib/poollint/configuration.rb', line 67 def suspicion_limit suspicion_log_size end |
#suspicion_limit=(value) ⇒ Object
71 72 73 |
# File 'lib/poollint/configuration.rb', line 71 def suspicion_limit=(value) self.suspicion_log_size = value end |
#test_environment? ⇒ Boolean
75 76 77 |
# File 'lib/poollint/configuration.rb', line 75 def test_environment? environment.to_s == "test" end |
#validate! ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/poollint/configuration.rb', line 79 def validate! validate_choices! validate_flags! validate_probability! validate_positive_number!(:inspection_timeout, inspection_timeout) validate_positive_integer!(:suspicion_log_size, suspicion_log_size) validate_ignore_if! validate_allowed_settings! self.watched_settings = Array(watched_settings).map { |name| normalize_setting(name) }.uniq self.mysql_watched_settings = normalize_mysql_settings self end |