Class: TIMEx::Configuration

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

Overview

Mutable process-wide defaults for #deadline, propagation, telemetry, and clock selection.

Read through configuration; updates should go through configure so in-flight callers never observe a half-mutated instance.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializevoid

Builds defaults aligned with conservative production behavior.



24
25
26
27
28
29
30
31
32
# File 'lib/timex/configuration.rb', line 24

def initialize
  @default_strategy = :cooperative
  @default_on_timeout = :raise
  @auto_check_default = false
  @auto_check_interval = 1000
  @telemetry_adapter = nil
  @clock = nil
  @skew_tolerance_ms = Deadline::DEFAULT_SKEW_TOLERANCE_MS
end

Instance Attribute Details

#auto_check_defaultObject

Returns the value of attribute auto_check_default.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def auto_check_default
  @auto_check_default
end

#auto_check_intervalObject

Returns the value of attribute auto_check_interval.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def auto_check_interval
  @auto_check_interval
end

#clockObject

Returns the value of attribute clock.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def clock
  @clock
end

#default_on_timeoutObject

Returns the value of attribute default_on_timeout.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def default_on_timeout
  @default_on_timeout
end

#default_strategyObject

Returns the value of attribute default_strategy.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def default_strategy
  @default_strategy
end

#skew_tolerance_msObject

Returns the value of attribute skew_tolerance_ms.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def skew_tolerance_ms
  @skew_tolerance_ms
end

#telemetry_adapterObject

Returns the value of attribute telemetry_adapter.



18
19
20
# File 'lib/timex/configuration.rb', line 18

def telemetry_adapter
  @telemetry_adapter
end

Instance Method Details

#initialize_copy(source) ⇒ void

Note:

Current fields are primitives; this is defensive for future container fields.

This method returns an undefined value.

Duplicates mutable Array/Hash fields after dup so nested configuration cannot leak mutations across snapshots.



107
108
109
110
111
112
113
# File 'lib/timex/configuration.rb', line 107

def initialize_copy(source)
  super
  instance_variables.each do |iv|
    val = instance_variable_get(iv)
    instance_variable_set(iv, val.dup) if val.is_a?(Array) || val.is_a?(Hash)
  end
end