Module: DistribCore::Configuration
- Defined in:
- lib/distrib_core/configuration.rb
Overview
This module contains shared attrs instantiated by specific configuration classes.
Constant Summary collapse
- TIMEOUT_STRATEGIES =
%i[repush release].freeze
Instance Attribute Summary collapse
- #before_test_report ⇒ Object
-
#debug_logger ⇒ Logger
private
Debugging logger.
- #drb ⇒ Object
-
#drb_tcp_socket_connection_timeout ⇒ Object
Returns the value of attribute drb_tcp_socket_connection_timeout.
-
#error_handler ⇒ Object
Object to handle errors from workers.
- #first_test_picked_timeout ⇒ Object
-
#leader_connection_attempts ⇒ Object
Returns the value of attribute leader_connection_attempts.
- #logger ⇒ Logger
- #on_finish ⇒ Object
- #test_timeout ⇒ Object
-
#tests_processing_stopped_timeout ⇒ Object
Returns the value of attribute tests_processing_stopped_timeout.
-
#tests_provider ⇒ Proc, Object#call
Provider for tests to execute.
-
#timeout_strategy ⇒ Object
Returns the value of attribute timeout_strategy.
Class Method Summary collapse
-
.current ⇒ DistribCore::Configuration
Global configuration.
-
.current=(configuration) ⇒ Object
Set global configuration.
Instance Method Summary collapse
-
#broadcaster ⇒ LoggerBroadcaster
private
Main logging interface used by distrib.
-
#initialize ⇒ Object
Initialize configuration with default values and set it to Configuration.current.
-
#timeout_for(test) ⇒ Float
Gives a timeout for a particular test based on ‘#test_timeout`.
Instance Attribute Details
#before_test_report ⇒ Object
76 77 78 |
# File 'lib/distrib_core/configuration.rb', line 76 def before_test_report @before_test_report end |
#debug_logger ⇒ Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Debugging logger. However user configures ‘logger`, this one collects messages logged at all levels.
157 158 159 |
# File 'lib/distrib_core/configuration.rb', line 157 def debug_logger @debug_logger ||= Logger.new('distrib.log', level: :debug) end |
#drb ⇒ Object
68 69 70 |
# File 'lib/distrib_core/configuration.rb', line 68 def drb @drb end |
#drb_tcp_socket_connection_timeout ⇒ Object
Returns the value of attribute drb_tcp_socket_connection_timeout.
92 93 94 |
# File 'lib/distrib_core/configuration.rb', line 92 def drb_tcp_socket_connection_timeout @drb_tcp_socket_connection_timeout end |
#error_handler ⇒ Object
Object to handle errors from workers
116 117 118 |
# File 'lib/distrib_core/configuration.rb', line 116 def error_handler @error_handler || raise(NotImplementedError) end |
#first_test_picked_timeout ⇒ Object
62 63 64 |
# File 'lib/distrib_core/configuration.rb', line 62 def first_test_picked_timeout @first_test_picked_timeout end |
#leader_connection_attempts ⇒ Object
Returns the value of attribute leader_connection_attempts.
92 93 94 |
# File 'lib/distrib_core/configuration.rb', line 92 def leader_connection_attempts @leader_connection_attempts end |
#logger ⇒ Logger
131 132 133 |
# File 'lib/distrib_core/configuration.rb', line 131 def logger @logger ||= Logger.new($stdout, level: :info) end |
#on_finish ⇒ Object
84 85 86 |
# File 'lib/distrib_core/configuration.rb', line 84 def on_finish @on_finish end |
#test_timeout ⇒ Object
56 57 58 |
# File 'lib/distrib_core/configuration.rb', line 56 def test_timeout @test_timeout end |
#tests_processing_stopped_timeout ⇒ Object
Returns the value of attribute tests_processing_stopped_timeout.
92 93 94 |
# File 'lib/distrib_core/configuration.rb', line 92 def tests_processing_stopped_timeout @tests_processing_stopped_timeout end |
#tests_provider ⇒ Proc, Object#call
Provider for tests to execute
111 112 113 |
# File 'lib/distrib_core/configuration.rb', line 111 def tests_provider @tests_provider || raise(NotImplementedError) end |
#timeout_strategy ⇒ Object
Returns the value of attribute timeout_strategy.
93 94 95 |
# File 'lib/distrib_core/configuration.rb', line 93 def timeout_strategy @timeout_strategy end |
Class Method Details
.current ⇒ DistribCore::Configuration
Returns global configuration.
22 23 24 |
# File 'lib/distrib_core/configuration.rb', line 22 def current @current || raise('Configuration is not set') end |
.current=(configuration) ⇒ Object
Set global configuration. Can be set only one time
15 16 17 18 19 |
# File 'lib/distrib_core/configuration.rb', line 15 def current=(configuration) raise('Configuration is already set') if @current && @current != configuration @current = configuration end |
Instance Method Details
#broadcaster ⇒ LoggerBroadcaster
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Main logging interface used by distrib.
148 149 150 |
# File 'lib/distrib_core/configuration.rb', line 148 def broadcaster @broadcaster ||= LoggerBroadcaster.new([logger, debug_logger]) end |
#initialize ⇒ Object
Initialize configuration with default values and set it to current
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/distrib_core/configuration.rb', line 96 def initialize DistribCore::Configuration.current = self @test_timeout = 60 # 1 minute @first_test_picked_timeout = 10 * 60 # 10 minutes @tests_processing_stopped_timeout = 5 * 60 # 5 minutes @drb = { safe_level: 1 } @drb_tcp_socket_connection_timeout = 5 # 5 seconds @leader_connection_attempts = 200 self.timeout_strategy = :repush end |
#timeout_for(test) ⇒ Float
Gives a timeout for a particular test based on ‘#test_timeout`
126 127 128 |
# File 'lib/distrib_core/configuration.rb', line 126 def timeout_for(test) test_timeout.respond_to?(:call) ? test_timeout.call(test) : test_timeout end |