Class: Specbandit::Configuration
- Inherits:
-
Object
- Object
- Specbandit::Configuration
- Defined in:
- lib/specbandit/configuration.rb
Constant Summary collapse
- DEFAULT_REDIS_URL =
'redis://localhost:6379'- DEFAULT_BATCH_SIZE =
5- DEFAULT_KEY_TTL =
A single TTL governs every key specbandit writes: the shared queue, its published marker, the per-runner rerun key and the failed key. It defaults to 1 week because re-runs can happen hours or days after the original run, and the rerun key + published marker must still be alive when they do.
604_800- DEFAULT_ADAPTER =
1 week in seconds
'cli'- DEFAULT_REDIS_MAX_ATTEMPTS =
Redis connection resilience. Redis is a best-effort coordination store for a distributed test run, and CI runners can sit a WAN hop away from it (e.g. cross-datacenter mesh), so a transient blip must not red the build. We retry a handful of times with capped exponential backoff, and give the underlying client explicit connect/read/write timeouts + reconnects rather than relying on library defaults.
5- DEFAULT_REDIS_CONNECT_TIMEOUT =
3.0- DEFAULT_REDIS_TIMEOUT =
5.0- DEFAULT_REDIS_RECONNECT_ATTEMPTS =
3
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#command ⇒ Object
Returns the value of attribute command.
-
#command_opts ⇒ Object
Returns the value of attribute command_opts.
-
#key ⇒ Object
Returns the value of attribute key.
-
#key_failed ⇒ Object
Returns the value of attribute key_failed.
-
#key_rerun ⇒ Object
Returns the value of attribute key_rerun.
-
#key_ttl ⇒ Object
Returns the value of attribute key_ttl.
-
#redis_connect_timeout ⇒ Object
Returns the value of attribute redis_connect_timeout.
-
#redis_max_attempts ⇒ Object
Returns the value of attribute redis_max_attempts.
-
#redis_reconnect_attempts ⇒ Object
Returns the value of attribute redis_reconnect_attempts.
-
#redis_timeout ⇒ Object
Returns the value of attribute redis_timeout.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
-
#report ⇒ Object
Returns the value of attribute report.
-
#rspec_opts ⇒ Object
Returns the value of attribute rspec_opts.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/specbandit/configuration.rb', line 32 def initialize @redis_url = ENV.fetch('SPECBANDIT_REDIS_URL', DEFAULT_REDIS_URL) @batch_size = Integer(ENV.fetch('SPECBANDIT_BATCH_SIZE', DEFAULT_BATCH_SIZE)) @key = ENV.fetch('SPECBANDIT_KEY', nil) @rspec_opts = parse_rspec_opts(ENV.fetch('SPECBANDIT_RSPEC_OPTS', nil)) @key_ttl = Integer(ENV.fetch('SPECBANDIT_KEY_TTL', DEFAULT_KEY_TTL)) @key_rerun = ENV.fetch('SPECBANDIT_KEY_RERUN', nil) @verbose = env_truthy?('SPECBANDIT_VERBOSE') @adapter = ENV.fetch('SPECBANDIT_ADAPTER', DEFAULT_ADAPTER) @command = ENV.fetch('SPECBANDIT_COMMAND', nil) @command_opts = parse_space_separated(ENV.fetch('SPECBANDIT_COMMAND_OPTS', nil)) @key_failed = ENV.fetch('SPECBANDIT_KEY_FAILED', nil) @report = ENV.fetch('SPECBANDIT_REPORT', nil) @redis_max_attempts = Integer(ENV.fetch('SPECBANDIT_REDIS_MAX_ATTEMPTS', DEFAULT_REDIS_MAX_ATTEMPTS)) @redis_connect_timeout = Float(ENV.fetch('SPECBANDIT_REDIS_CONNECT_TIMEOUT', DEFAULT_REDIS_CONNECT_TIMEOUT)) @redis_timeout = Float(ENV.fetch('SPECBANDIT_REDIS_TIMEOUT', DEFAULT_REDIS_TIMEOUT)) @redis_reconnect_attempts = Integer(ENV.fetch('SPECBANDIT_REDIS_RECONNECT_ATTEMPTS', DEFAULT_REDIS_RECONNECT_ATTEMPTS)) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def adapter @adapter end |
#batch_size ⇒ Object
Returns the value of attribute batch_size.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def batch_size @batch_size end |
#command ⇒ Object
Returns the value of attribute command.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def command @command end |
#command_opts ⇒ Object
Returns the value of attribute command_opts.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def command_opts @command_opts end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key @key end |
#key_failed ⇒ Object
Returns the value of attribute key_failed.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key_failed @key_failed end |
#key_rerun ⇒ Object
Returns the value of attribute key_rerun.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key_rerun @key_rerun end |
#key_ttl ⇒ Object
Returns the value of attribute key_ttl.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key_ttl @key_ttl end |
#redis_connect_timeout ⇒ Object
Returns the value of attribute redis_connect_timeout.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def redis_connect_timeout @redis_connect_timeout end |
#redis_max_attempts ⇒ Object
Returns the value of attribute redis_max_attempts.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def redis_max_attempts @redis_max_attempts end |
#redis_reconnect_attempts ⇒ Object
Returns the value of attribute redis_reconnect_attempts.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def redis_reconnect_attempts @redis_reconnect_attempts end |
#redis_timeout ⇒ Object
Returns the value of attribute redis_timeout.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def redis_timeout @redis_timeout end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def redis_url @redis_url end |
#report ⇒ Object
Returns the value of attribute report.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def report @report end |
#rspec_opts ⇒ Object
Returns the value of attribute rspec_opts.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def rspec_opts @rspec_opts end |
#verbose ⇒ Object
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def verbose @verbose end |
Instance Method Details
#validate! ⇒ Object
52 53 54 55 56 57 |
# File 'lib/specbandit/configuration.rb', line 52 def validate! raise Error, 'key is required (set via --key or SPECBANDIT_KEY)' if key.nil? || key.empty? raise Error, 'batch_size must be a positive integer' unless batch_size.positive? raise Error, 'key_ttl must be a positive integer' unless key_ttl.positive? raise Error, 'redis_max_attempts must be a positive integer' unless redis_max_attempts.positive? end |