Class: Contrast::Components::Sampling::Interface

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
InstanceMethods, Contrast::Config::BaseConfiguration
Defined in:
lib/contrast/components/sampling.rb

Overview

:nodoc:

Constant Summary collapse

CANON_NAME =
'assess.sampling'
CONFIG_VALUES =
%w[enable baseline request_frequency response_frequency window_ms].cs__freeze

Constants included from Constants

Constants::DEFAULT_SAMPLING_BASELINE, Constants::DEFAULT_SAMPLING_ENABLED, Constants::DEFAULT_SAMPLING_REQUEST_FREQUENCY, Constants::DEFAULT_SAMPLING_RESPONSE_FREQUENCY, Constants::DEFAULT_SAMPLING_WINDOW_MS

Constants included from ComponentBase

ComponentBase::ENABLE

Constants included from Contrast::Config::Diagnostics::Tools

Contrast::Config::Diagnostics::Tools::CHECK

Constants included from Contrast::Config::Diagnostics::SingletonTools

Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK

Constants included from Contrast::Config::BaseConfiguration

Contrast::Config::BaseConfiguration::AT_UNDERSCORE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

reset_sampling_control, sampling_control, sampling_enabled?

Methods included from ComponentBase

#config_values, #false?, #file_exists?, #stringify_array, #true?, #valid_cert?

Methods included from Contrast::Config::Diagnostics::Tools

#add_effective_config_values, #add_single_effective_value

Methods included from Contrast::Config::Diagnostics::SingletonTools

#flatten_settings, #to_config_values, #update_config, #value_to_s

Methods included from Contrast::Config::BaseConfiguration

#to_contrast_hash

Constructor Details

#initialize(hsh = {}) ⇒ Interface

Returns a new instance of Interface.



129
130
131
132
133
134
135
136
137
138
# File 'lib/contrast/components/sampling.rb', line 129

def initialize hsh = {}
  @canon_name = CANON_NAME
  return unless hsh

  @enable = hsh[:enable]
  @baseline = hsh[:baseline]
  @request_frequency = hsh[:request_frequency]
  @response_frequency = hsh[:response_frequency]
  @window_ms = hsh[:window_ms]
end

Instance Attribute Details

#baselineInteger?

Returns:

  • (Integer, nil)


119
120
121
# File 'lib/contrast/components/sampling.rb', line 119

def baseline
  @baseline
end

#canon_nameString

Returns:



127
128
129
# File 'lib/contrast/components/sampling.rb', line 127

def canon_name
  @canon_name
end

#enableBoolean?

Returns:

  • (Boolean, nil)


117
118
119
# File 'lib/contrast/components/sampling.rb', line 117

def enable
  @enable
end

#request_frequencyInteger?

Returns:

  • (Integer, nil)


121
122
123
# File 'lib/contrast/components/sampling.rb', line 121

def request_frequency
  @request_frequency
end

#response_frequencyInteger?

Returns:

  • (Integer, nil)


123
124
125
# File 'lib/contrast/components/sampling.rb', line 123

def response_frequency
  @response_frequency
end

#window_msInteger?

Returns:

  • (Integer, nil)


125
126
127
# File 'lib/contrast/components/sampling.rb', line 125

def window_ms
  @window_ms
end

Instance Method Details

#to_effective_config(effective_config) ⇒ Object

Converts current configuration to effective config values class and appends them to EffectiveConfig class.

Parameters:



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/contrast/components/sampling.rb', line 144

def to_effective_config effective_config
  confirm_sources

  add_single_effective_value(effective_config, 'enable', sampling_control[:enabled], canon_name)
  add_single_effective_value(effective_config, 'baseline', sampling_control[:baseline], canon_name)
  add_single_effective_value(effective_config, 'window_ms', sampling_control[:window], canon_name)
  add_single_effective_value(effective_config,
                             'request_frequency', sampling_control[:request_frequency], canon_name)
  add_single_effective_value(effective_config,
                             'response_frequency', sampling_control[:response_frequency], canon_name)
end