Class: Stoplight::Wiring::ConfigurationDsl

Inherits:
Object
  • Object
show all
Defined in:
lib/stoplight/wiring/configuration_dsl.rb,
sig/_private/stoplight/wiring/configuration_dsl.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: T.undefined, cool_off_time: T.undefined, threshold: T.undefined, recovery_threshold: T.undefined, window_size: T.undefined, tracked_errors: T.undefined, skipped_errors: T.undefined, data_store: T.undefined, error_notifier: T.undefined, notifiers: T.undefined, traffic_control: T.undefined, traffic_recovery: T.undefined) ⇒ ConfigurationDsl

Returns a new instance of ConfigurationDsl.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 6

def initialize(
  name: T.undefined,
  cool_off_time: T.undefined,
  threshold: T.undefined,
  recovery_threshold: T.undefined,
  window_size: T.undefined,
  tracked_errors: T.undefined,
  skipped_errors: T.undefined,
  data_store: T.undefined,
  error_notifier: T.undefined,
  notifiers: T.undefined,
  traffic_control: T.undefined,
  traffic_recovery: T.undefined
)
  @name = name
  @cool_off_time = cool_off_time
  @threshold = threshold
  @recovery_threshold = recovery_threshold
  @window_size = window_size
  @tracked_errors = tracked_errors
  @skipped_errors = skipped_errors
  @traffic_control = traffic_control
  @traffic_recovery = traffic_recovery
  @error_notifier = error_notifier
  @data_store = data_store
  @notifiers = notifiers
end

Instance Attribute Details

#cool_off_timeoptional[duration] (readonly)

Returns the value of attribute cool_off_time.

Returns:

  • (optional[duration])


56
57
58
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 56

def cool_off_time
  @cool_off_time
end

#data_storeoptional[data_store] (readonly)

Returns the value of attribute data_store.

Returns:



61
62
63
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 61

def data_store
  @data_store
end

#error_notifieroptional[error_notifier] (readonly)

Returns the value of attribute error_notifier.

Returns:



60
61
62
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 60

def error_notifier
  @error_notifier
end

#nameoptional[String] (readonly)

Returns the value of attribute name.

Returns:

  • (optional[String])


55
56
57
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 55

def name
  @name
end

#notifiersoptional[Array[state_transition_notifier]] (readonly)

Returns the value of attribute notifiers.

Returns:

  • (optional[Array[state_transition_notifier]])


62
63
64
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 62

def notifiers
  @notifiers
end

#recovery_thresholdoptional[Integer] (readonly)

Returns the value of attribute recovery_threshold.

Returns:

  • (optional[Integer])


58
59
60
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 58

def recovery_threshold
  @recovery_threshold
end

#thresholdoptional[percentage | Integer] (readonly)

Returns the value of attribute threshold.

Returns:

  • (optional[percentage | Integer])


57
58
59
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 57

def threshold
  @threshold
end

#window_sizeoptional[duration?] (readonly)

Returns the value of attribute window_size.

Returns:

  • (optional[duration?])


59
60
61
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 59

def window_size
  @window_size
end

Instance Method Details

#configure!(default_config) ⇒ Domain::Config

Parameters:

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 34

def configure!(default_config)
  ConfigCompatibilityValidator.call(
    config: default_config.with(
      name:,
      cool_off_time:,
      threshold:,
      recovery_threshold:,
      window_size:,
      tracked_errors:,
      skipped_errors:,
      traffic_control:,
      traffic_recovery:,
      error_notifier:,
      data_store:,
      notifiers:
    )
  )
end

#skipped_errorsoptional[Array[_ExceptionMatcher]]

Returns:



73
74
75
76
77
78
79
80
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 73

def skipped_errors
  value = @skipped_errors
  if value.is_a?(Undefined)
    value
  else
    Array(value)
  end
end

#tracked_errorsoptional[Array[_ExceptionMatcher]]

Returns:



64
65
66
67
68
69
70
71
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 64

def tracked_errors
  value = @tracked_errors
  if value.is_a?(Undefined)
    value
  else
    Array(value)
  end
end

#traffic_controloptional[Domain::_TrafficControl]

Returns:



82
83
84
85
86
87
88
89
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 82

def traffic_control
  value = @traffic_control
  if value.is_a?(Undefined)
    value
  else
    LightFactory::TrafficControlDsl.call(value)
  end
end

#traffic_recoveryoptional[Domain::_TrafficRecovery]

Returns:



91
92
93
94
95
96
97
98
# File 'lib/stoplight/wiring/configuration_dsl.rb', line 91

def traffic_recovery
  value = @traffic_recovery
  if value.is_a?(Undefined)
    value
  else
    LightFactory::TrafficRecoveryDsl.call(value)
  end
end