stoplight 5.8.3 → 6.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/LICENSE.md +1 -0
  4. data/README.md +132 -79
  5. data/UPGRADING.md +265 -6
  6. data/lib/stoplight/admin/actions/action.rb +4 -12
  7. data/lib/stoplight/admin/actions/lock.rb +12 -9
  8. data/lib/stoplight/admin/actions/lock_all.rb +27 -0
  9. data/lib/stoplight/admin/actions/remove.rb +12 -9
  10. data/lib/stoplight/admin/actions/stats.rb +15 -12
  11. data/lib/stoplight/admin/actions/unlock.rb +10 -9
  12. data/lib/stoplight/admin/assets/apple-touch-icon.png +0 -0
  13. data/lib/stoplight/admin/assets/favicon.ico +0 -0
  14. data/lib/stoplight/admin/assets/flowbite.min.css +2 -0
  15. data/lib/stoplight/admin/assets/flowbite.min.js +1 -0
  16. data/lib/stoplight/admin/assets/icon.svg +7 -0
  17. data/lib/stoplight/admin/assets/turbo.es2017-esm.min.js +34 -0
  18. data/lib/stoplight/admin/config_registry.rb +40 -0
  19. data/lib/stoplight/admin/dependencies.rb +29 -28
  20. data/lib/stoplight/admin/helpers.rb +50 -17
  21. data/lib/stoplight/admin/light_view.rb +184 -0
  22. data/lib/stoplight/admin/lights_stats.rb +7 -9
  23. data/lib/stoplight/admin/views/_card.erb +19 -21
  24. data/lib/stoplight/admin/views/index.erb +9 -3
  25. data/lib/stoplight/admin/views/layout.erb +45 -13
  26. data/lib/stoplight/admin.rb +110 -21
  27. data/lib/stoplight/data_store.rb +18 -8
  28. data/lib/stoplight/domain/config.rb +4 -1
  29. data/lib/stoplight/domain/error_tracking_policy.rb +9 -0
  30. data/lib/stoplight/domain/failure.rb +4 -0
  31. data/lib/stoplight/domain/id.rb +13 -0
  32. data/lib/stoplight/domain/light.rb +35 -77
  33. data/lib/stoplight/domain/lock_control.rb +55 -0
  34. data/lib/stoplight/domain/matcher_validator.rb +24 -0
  35. data/lib/stoplight/domain/state_snapshot.rb +2 -6
  36. data/lib/stoplight/domain/strategies/green_run_strategy.rb +33 -19
  37. data/lib/stoplight/domain/strategies/red_run_strategy.rb +8 -2
  38. data/lib/stoplight/domain/strategies/yellow_run_strategy.rb +56 -32
  39. data/lib/stoplight/domain/telemetry/bus.rb +90 -0
  40. data/lib/stoplight/domain/telemetry/consumer.rb +18 -0
  41. data/lib/stoplight/domain/telemetry/emitter.rb +45 -0
  42. data/lib/stoplight/domain/telemetry/envelope.rb +15 -0
  43. data/lib/stoplight/domain/telemetry/failure.rb +13 -0
  44. data/lib/stoplight/domain/telemetry/light_registered.rb +12 -0
  45. data/lib/stoplight/domain/telemetry/lock_changed.rb +19 -0
  46. data/lib/stoplight/domain/telemetry/metrics.rb +15 -0
  47. data/lib/stoplight/domain/telemetry/recovery_failed.rb +20 -0
  48. data/lib/stoplight/domain/telemetry/recovery_probe_completed.rb +15 -0
  49. data/lib/stoplight/domain/telemetry/recovery_started.rb +18 -0
  50. data/lib/stoplight/domain/telemetry/recovery_succeeded.rb +19 -0
  51. data/lib/stoplight/domain/telemetry/run_completed.rb +17 -0
  52. data/lib/stoplight/domain/telemetry/run_recorder.rb +58 -0
  53. data/lib/stoplight/domain/telemetry/settings.rb +21 -0
  54. data/lib/stoplight/domain/telemetry/state_transitioned.rb +11 -0
  55. data/lib/stoplight/domain/telemetry/subscription.rb +11 -0
  56. data/lib/stoplight/domain/telemetry/traffic_breached.rb +20 -0
  57. data/lib/stoplight/domain/tracker/recovery_probe.rb +61 -17
  58. data/lib/stoplight/domain/tracker/request.rb +17 -8
  59. data/lib/stoplight/domain/traffic_control/consecutive_errors.rb +13 -3
  60. data/lib/stoplight/domain/traffic_control/error_rate.rb +16 -12
  61. data/lib/stoplight/domain/traffic_recovery/consecutive_successes.rb +9 -3
  62. data/lib/stoplight/error.rb +10 -1
  63. data/lib/stoplight/infrastructure/config_serializer.rb +50 -0
  64. data/lib/stoplight/infrastructure/fail_safe/error_notifier.rb +25 -0
  65. data/lib/stoplight/infrastructure/fail_safe/storage/registry.rb +68 -0
  66. data/lib/stoplight/infrastructure/memory/storage/registry.rb +18 -0
  67. data/lib/stoplight/infrastructure/memory/storage/unbounded_metrics.rb +29 -32
  68. data/lib/stoplight/infrastructure/memory/storage/window_metrics/sliding_window.rb +74 -0
  69. data/lib/stoplight/infrastructure/memory/storage/window_metrics.rb +25 -24
  70. data/lib/stoplight/infrastructure/notifier/fail_safe.rb +3 -8
  71. data/lib/stoplight/infrastructure/notifier/generic.rb +3 -3
  72. data/lib/stoplight/infrastructure/redis/key.rb +25 -0
  73. data/lib/stoplight/infrastructure/redis/storage/now.lua +9 -0
  74. data/lib/stoplight/infrastructure/redis/storage/recovery_lock.rb +2 -4
  75. data/lib/stoplight/infrastructure/redis/storage/recovery_metrics.rb +1 -1
  76. data/lib/stoplight/infrastructure/redis/storage/registry.rb +73 -0
  77. data/lib/stoplight/infrastructure/redis/storage/scripting.rb +54 -3
  78. data/lib/stoplight/infrastructure/redis/storage/state/transition_to_green.lua +3 -1
  79. data/lib/stoplight/infrastructure/redis/storage/state/transition_to_red.lua +4 -2
  80. data/lib/stoplight/infrastructure/redis/storage/state/transition_to_yellow.lua +3 -1
  81. data/lib/stoplight/infrastructure/redis/storage/state.rb +8 -8
  82. data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_failure.lua +20 -21
  83. data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics/record_success.lua +11 -19
  84. data/lib/stoplight/infrastructure/redis/storage/unbounded_metrics.rb +20 -16
  85. data/lib/stoplight/infrastructure/redis/storage/window_metrics/_evict.lua +44 -0
  86. data/lib/stoplight/infrastructure/redis/storage/window_metrics/metrics_snapshot.lua +14 -21
  87. data/lib/stoplight/infrastructure/redis/storage/window_metrics/record_failure.lua +38 -36
  88. data/lib/stoplight/infrastructure/redis/storage/window_metrics/record_success.lua +23 -30
  89. data/lib/stoplight/infrastructure/redis/storage/window_metrics.rb +45 -135
  90. data/lib/stoplight/infrastructure/system_clock.rb +4 -0
  91. data/lib/stoplight/telemetry.rb +19 -0
  92. data/lib/stoplight/types.rb +15 -2
  93. data/lib/stoplight/version.rb +1 -1
  94. data/lib/stoplight/wiring/config_compatibility_validator.rb +25 -2
  95. data/lib/stoplight/wiring/default.rb +1 -1
  96. data/lib/stoplight/wiring/default_config.rb +2 -1
  97. data/lib/stoplight/wiring/default_configuration.rb +3 -2
  98. data/lib/stoplight/wiring/external_caller.rb +27 -0
  99. data/lib/stoplight/wiring/fail_safe_config.rb +11 -0
  100. data/lib/stoplight/wiring/global_state.rb +93 -0
  101. data/lib/stoplight/wiring/{light_factory → light_configuration_dsl}/traffic_control_dsl.rb +3 -5
  102. data/lib/stoplight/wiring/{light_factory → light_configuration_dsl}/traffic_recovery_dsl.rb +2 -2
  103. data/lib/stoplight/wiring/light_configuration_dsl.rb +97 -0
  104. data/lib/stoplight/wiring/light_factory.rb +154 -97
  105. data/lib/stoplight/wiring/notifier_bridge.rb +33 -0
  106. data/lib/stoplight/wiring/redis/backend.rb +1 -1
  107. data/lib/stoplight/wiring/system/storage.rb +69 -0
  108. data/lib/stoplight/wiring/system.rb +125 -56
  109. data/lib/stoplight/wiring/{configuration_dsl.rb → system_configuration_dsl.rb} +13 -43
  110. data/lib/stoplight.rb +50 -194
  111. data/sig/sinatra/base.rbs +6 -0
  112. data/sig/stdlib/securerandom.rbs +4 -0
  113. data/sig/stoplight/admin/actions/action.rbs +10 -0
  114. data/sig/stoplight/admin/actions/lock.rbs +17 -0
  115. data/sig/stoplight/admin/actions/lock_all.rbs +17 -0
  116. data/sig/stoplight/admin/actions/remove.rbs +22 -0
  117. data/sig/stoplight/admin/actions/stats.rbs +28 -0
  118. data/sig/stoplight/admin/actions/unlock.rbs +17 -0
  119. data/sig/stoplight/admin/config_registry.rbs +20 -0
  120. data/sig/stoplight/admin/dependencies.rbs +16 -0
  121. data/sig/stoplight/admin/helpers.rbs +17 -0
  122. data/sig/stoplight/admin/light_view.rbs +39 -0
  123. data/sig/stoplight/admin/lights_stats.rbs +30 -0
  124. data/sig/stoplight/admin.rbs +14 -0
  125. data/sig/stoplight/color.rbs +3 -3
  126. data/sig/{_private/stoplight/data_store.rbs → stoplight/data_store/base.rbs} +1 -0
  127. data/sig/stoplight/data_store/memory.rbs +9 -0
  128. data/sig/stoplight/data_store/redis.rbs +17 -0
  129. data/sig/{_private/stoplight → stoplight}/domain/config.rbs +28 -24
  130. data/sig/{_private/stoplight → stoplight}/domain/error_tracking_policy.rbs +4 -0
  131. data/sig/{_private/stoplight → stoplight}/domain/failure.rbs +2 -0
  132. data/sig/stoplight/domain/id.rbs +7 -0
  133. data/sig/stoplight/domain/light.rbs +39 -0
  134. data/sig/{_private/stoplight → stoplight}/domain/light_info.rbs +1 -5
  135. data/sig/stoplight/domain/lock_control.rbs +16 -0
  136. data/sig/stoplight/domain/matcher_validator.rbs +11 -0
  137. data/sig/{_private/stoplight → stoplight}/domain/ports/clock.rbs +6 -0
  138. data/sig/stoplight/domain/ports/data_store.rbs +9 -0
  139. data/sig/stoplight/domain/ports/error_notifier.rbs +12 -0
  140. data/sig/stoplight/domain/ports/exception_matcher.rbs +10 -0
  141. data/sig/{_private/stoplight → stoplight}/domain/ports/metrics_store.rbs +2 -2
  142. data/sig/stoplight/domain/ports/registry.rbs +13 -0
  143. data/sig/{_private/stoplight → stoplight}/domain/ports/run_strategy.rbs +2 -1
  144. data/sig/stoplight/domain/ports/state_transition_notifier.rbs +18 -0
  145. data/sig/stoplight/domain/ports/telemetry.rbs +28 -0
  146. data/sig/stoplight/domain/ports/telemetry_publisher.rbs +14 -0
  147. data/sig/{_private/stoplight → stoplight}/domain/ports/traffic_control.rbs +7 -0
  148. data/sig/{_private/stoplight → stoplight}/domain/ports/traffic_recovery.rbs +2 -3
  149. data/sig/stoplight/domain/strategies/green_run_strategy.rbs +22 -0
  150. data/sig/stoplight/domain/strategies/red_run_strategy.rbs +19 -0
  151. data/sig/{_private/stoplight → stoplight}/domain/strategies/yellow_run_strategy.rbs +23 -12
  152. data/sig/stoplight/domain/telemetry/bus.rbs +49 -0
  153. data/sig/stoplight/domain/telemetry/consumer.rbs +13 -0
  154. data/sig/stoplight/domain/telemetry/emitter.rbs +51 -0
  155. data/sig/stoplight/domain/telemetry/envelope.rbs +30 -0
  156. data/sig/stoplight/domain/telemetry/failure.rbs +23 -0
  157. data/sig/stoplight/domain/telemetry/light_registered.rbs +23 -0
  158. data/sig/stoplight/domain/telemetry/lock_changed.rbs +31 -0
  159. data/sig/stoplight/domain/telemetry/metrics.rbs +27 -0
  160. data/sig/stoplight/domain/telemetry/recovery_failed.rbs +36 -0
  161. data/sig/stoplight/domain/telemetry/recovery_probe_completed.rbs +29 -0
  162. data/sig/stoplight/domain/telemetry/recovery_started.rbs +26 -0
  163. data/sig/stoplight/domain/telemetry/recovery_succeeded.rbs +31 -0
  164. data/sig/stoplight/domain/telemetry/run_completed.rbs +38 -0
  165. data/sig/stoplight/domain/telemetry/run_recorder.rbs +27 -0
  166. data/sig/stoplight/domain/telemetry/settings.rbs +47 -0
  167. data/sig/stoplight/domain/telemetry/state_transitioned.rbs +11 -0
  168. data/sig/stoplight/domain/telemetry/subscription.rbs +9 -0
  169. data/sig/stoplight/domain/telemetry/traffic_breached.rbs +36 -0
  170. data/sig/stoplight/domain/telemetry/types.rbs +32 -0
  171. data/sig/{_private/stoplight → stoplight}/domain/tracker/recovery_probe.rbs +10 -6
  172. data/sig/{_private/stoplight → stoplight}/domain/tracker/request.rbs +3 -3
  173. data/sig/{_private/stoplight → stoplight}/domain/traffic_control/consecutive_errors.rbs +2 -0
  174. data/sig/{_private/stoplight → stoplight}/domain/traffic_control/error_rate.rbs +3 -2
  175. data/sig/{_private/stoplight → stoplight}/domain/traffic_recovery/consecutive_successes.rbs +2 -0
  176. data/sig/stoplight/domain/types.rbs +25 -0
  177. data/sig/stoplight/error.rbs +8 -0
  178. data/sig/stoplight/generators/rails_generators_base.rbs +11 -0
  179. data/sig/stoplight/infrastructure/config_serializer.rbs +12 -0
  180. data/sig/stoplight/infrastructure/fail_safe/error_notifier.rbs +13 -0
  181. data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/metrics.rbs +2 -2
  182. data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/recovery_lock.rbs +2 -2
  183. data/sig/stoplight/infrastructure/fail_safe/storage/registry.rbs +23 -0
  184. data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/state.rbs +4 -4
  185. data/sig/stoplight/infrastructure/memory/storage/registry.rbs +13 -0
  186. data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/state.rbs +3 -3
  187. data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/unbounded_metrics.rbs +7 -7
  188. data/sig/stoplight/infrastructure/memory/storage/window_metrics/sliding_window.rbs +27 -0
  189. data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/window_metrics.rbs +7 -7
  190. data/sig/stoplight/infrastructure/notifier/fail_safe.rbs +15 -0
  191. data/sig/{_private/stoplight → stoplight}/infrastructure/notifier/generic.rbs +1 -1
  192. data/sig/{_private/stoplight → stoplight}/infrastructure/notifier/io.rbs +1 -1
  193. data/sig/{_private/stoplight → stoplight}/infrastructure/notifier/logger.rbs +1 -1
  194. data/sig/stoplight/infrastructure/redis/key.rbs +10 -0
  195. data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/recovery_lock.rbs +2 -2
  196. data/sig/stoplight/infrastructure/redis/storage/registry.rbs +27 -0
  197. data/sig/stoplight/infrastructure/redis/storage/scripting.rbs +34 -0
  198. data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/state.rbs +4 -4
  199. data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/unbounded_metrics.rbs +8 -1
  200. data/sig/stoplight/infrastructure/redis/storage/window_metrics.rbs +35 -0
  201. data/sig/stoplight/infrastructure/types.rbs +6 -0
  202. data/sig/stoplight/notifier.rbs +1 -1
  203. data/sig/stoplight/ports/system.rbs +16 -10
  204. data/sig/stoplight/state.rbs +3 -3
  205. data/sig/stoplight/telemetry.rbs +17 -0
  206. data/sig/stoplight/types.rbs +9 -0
  207. data/sig/{_private/stoplight → stoplight}/wiring/config_compatibility_validator.rbs +2 -0
  208. data/sig/stoplight/wiring/default.rbs +26 -0
  209. data/sig/stoplight/wiring/default_configuration.rbs +39 -0
  210. data/sig/stoplight/wiring/external_caller.rbs +13 -0
  211. data/sig/stoplight/wiring/fail_safe_config.rbs +7 -0
  212. data/sig/stoplight/wiring/global_state.rbs +36 -0
  213. data/sig/{_private/stoplight/wiring/light_factory → stoplight/wiring/light_configuration_dsl}/traffic_control_dsl.rbs +1 -1
  214. data/sig/{_private/stoplight/wiring/light_factory → stoplight/wiring/light_configuration_dsl}/traffic_recovery_dsl.rbs +1 -1
  215. data/sig/stoplight/wiring/light_configuration_dsl.rbs +38 -0
  216. data/sig/stoplight/wiring/light_factory.rbs +78 -0
  217. data/sig/stoplight/wiring/notifier_bridge.rbs +15 -0
  218. data/sig/stoplight/wiring/notifier_factory.rbs +10 -0
  219. data/sig/{_private/stoplight → stoplight}/wiring/redis/backend.rbs +6 -6
  220. data/sig/stoplight/wiring/system/storage.rbs +35 -0
  221. data/sig/stoplight/wiring/system.rbs +30 -0
  222. data/sig/stoplight/wiring/system_configuration_dsl.rbs +39 -0
  223. data/sig/stoplight/wiring/types.rbs +6 -0
  224. data/sig/stoplight.rbs +37 -54
  225. metadata +190 -143
  226. data/lib/stoplight/admin/actions/lock_all_green.rb +0 -18
  227. data/lib/stoplight/admin/actions/lock_green.rb +0 -23
  228. data/lib/stoplight/admin/actions/lock_red.rb +0 -23
  229. data/lib/stoplight/admin/lights_repository/light.rb +0 -171
  230. data/lib/stoplight/admin/lights_repository.rb +0 -87
  231. data/lib/stoplight/domain/light/configuration_builder_interface.rb +0 -236
  232. data/lib/stoplight/infrastructure/fail_safe/data_store.rb +0 -152
  233. data/lib/stoplight/infrastructure/memory/data_store/metrics.rb +0 -27
  234. data/lib/stoplight/infrastructure/memory/data_store/recovery_lock_store.rb +0 -52
  235. data/lib/stoplight/infrastructure/memory/data_store/recovery_lock_token.rb +0 -17
  236. data/lib/stoplight/infrastructure/memory/data_store/sliding_window.rb +0 -74
  237. data/lib/stoplight/infrastructure/memory/data_store/state.rb +0 -21
  238. data/lib/stoplight/infrastructure/memory/data_store.rb +0 -342
  239. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/get_metrics.lua +0 -26
  240. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_failure.lua +0 -36
  241. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_failure.lua +0 -27
  242. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_recovery_probe_success.lua +0 -23
  243. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/record_success.lua +0 -35
  244. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/release_lock.lua +0 -6
  245. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_green.lua +0 -10
  246. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_red.lua +0 -10
  247. data/lib/stoplight/infrastructure/redis/data_store/lua_scripts/transition_to_yellow.lua +0 -9
  248. data/lib/stoplight/infrastructure/redis/data_store/recovery_lock_store.rb +0 -60
  249. data/lib/stoplight/infrastructure/redis/data_store/recovery_lock_token.rb +0 -28
  250. data/lib/stoplight/infrastructure/redis/data_store/scripting.rb +0 -73
  251. data/lib/stoplight/infrastructure/redis/data_store.rb +0 -516
  252. data/lib/stoplight/infrastructure/redis/storage/key_space.rb +0 -51
  253. data/lib/stoplight/infrastructure/storage/compatibility_metrics.rb +0 -41
  254. data/lib/stoplight/infrastructure/storage/compatibility_recovery_lock.rb +0 -33
  255. data/lib/stoplight/infrastructure/storage/compatibility_recovery_metrics.rb +0 -47
  256. data/lib/stoplight/infrastructure/storage/compatibility_state.rb +0 -44
  257. data/lib/stoplight/wiring/light_builder.rb +0 -198
  258. data/lib/stoplight/wiring/notifier_factory.rb +0 -26
  259. data/lib/stoplight/wiring/system/light_builder.rb +0 -47
  260. data/lib/stoplight/wiring/system/light_factory.rb +0 -64
  261. data/sig/_private/stoplight/domain/light.rbs +0 -25
  262. data/sig/_private/stoplight/domain/ports/data_store.rbs +0 -76
  263. data/sig/_private/stoplight/domain/ports/light_factory.rbs +0 -80
  264. data/sig/_private/stoplight/domain/strategies/green_run_strategy.rbs +0 -17
  265. data/sig/_private/stoplight/domain/strategies/red_run_strategy.rbs +0 -17
  266. data/sig/_private/stoplight/domain/tracker/base.rbs +0 -8
  267. data/sig/_private/stoplight/infrastructure/fail_safe/data_store.rbs +0 -26
  268. data/sig/_private/stoplight/infrastructure/memory/data_store/metrics.rbs +0 -25
  269. data/sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_store.rbs +0 -19
  270. data/sig/_private/stoplight/infrastructure/memory/data_store/recovery_lock_token.rbs +0 -17
  271. data/sig/_private/stoplight/infrastructure/memory/data_store/sliding_window.rbs +0 -27
  272. data/sig/_private/stoplight/infrastructure/memory/data_store/state.rbs +0 -17
  273. data/sig/_private/stoplight/infrastructure/memory/data_store.rbs +0 -30
  274. data/sig/_private/stoplight/infrastructure/notifier/fail_safe.rbs +0 -17
  275. data/sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_store.rbs +0 -24
  276. data/sig/_private/stoplight/infrastructure/redis/data_store/recovery_lock_token.rbs +0 -21
  277. data/sig/_private/stoplight/infrastructure/redis/data_store/scripting.rbs +0 -34
  278. data/sig/_private/stoplight/infrastructure/redis/data_store.rbs +0 -67
  279. data/sig/_private/stoplight/infrastructure/redis/storage/key_space.rbs +0 -19
  280. data/sig/_private/stoplight/infrastructure/redis/storage/scripting.rbs +0 -13
  281. data/sig/_private/stoplight/infrastructure/redis/storage/window_metrics.rbs +0 -34
  282. data/sig/_private/stoplight/infrastructure/storage/compatibility_metrics.rbs +0 -17
  283. data/sig/_private/stoplight/infrastructure/storage/compatibility_recovery_lock.rbs +0 -13
  284. data/sig/_private/stoplight/infrastructure/storage/compatibility_recovery_metrics.rbs +0 -14
  285. data/sig/_private/stoplight/infrastructure/storage/compatibility_state.rbs +0 -14
  286. data/sig/_private/stoplight/system/light_builder.rbs +0 -23
  287. data/sig/_private/stoplight/system/light_factory.rbs +0 -17
  288. data/sig/_private/stoplight/types.rbs +0 -6
  289. data/sig/_private/stoplight/wiring/configuration_dsl.rbs +0 -43
  290. data/sig/_private/stoplight/wiring/default.rbs +0 -26
  291. data/sig/_private/stoplight/wiring/default_configuration.rbs +0 -29
  292. data/sig/_private/stoplight/wiring/light_builder.rbs +0 -48
  293. data/sig/_private/stoplight/wiring/light_factory.rbs +0 -16
  294. data/sig/_private/stoplight/wiring/notifier_factory.rbs +0 -10
  295. data/sig/_private/stoplight/wiring/system.rbs +0 -15
  296. data/sig/_private/stoplight.rbs +0 -48
  297. data/sig/stoplight/data_store.rbs +0 -19
  298. data/sig/stoplight/ports/configuration.rbs +0 -19
  299. data/sig/stoplight/ports/exception_matcher.rbs +0 -8
  300. data/sig/stoplight/ports/light.rbs +0 -12
  301. data/sig/stoplight/ports/light_info.rbs +0 -5
  302. data/sig/stoplight/ports/state_transition_notifier.rbs +0 -15
  303. /data/sig/{_private/stoplight → stoplight}/common/deprecations.rbs +0 -0
  304. /data/sig/{_private/stoplight → stoplight}/domain/compatibility_result.rbs +0 -0
  305. /data/sig/{_private/stoplight → stoplight}/domain/metrics_snapshot.rbs +0 -0
  306. /data/sig/{_private/stoplight → stoplight}/domain/ports/recovery_lock_store.rbs +0 -0
  307. /data/sig/{_private/stoplight → stoplight}/domain/ports/recovery_lock_token.rbs +0 -0
  308. /data/sig/{_private/stoplight → stoplight}/domain/ports/state_store.rbs +0 -0
  309. /data/sig/{_private/stoplight → stoplight}/domain/state_snapshot.rbs +0 -0
  310. /data/sig/{_private/stoplight → stoplight}/domain/storage/recovery_lock_token.rbs +0 -0
  311. /data/sig/{_private/stoplight → stoplight}/domain/traffic_recovery.rbs +0 -0
  312. /data/sig/{_private → stoplight}/generators/stoplight/install/install_generator.rbs +0 -0
  313. /data/sig/{_private/stoplight → stoplight}/infrastructure/fail_safe/storage/recovery_lock_token.rbs +0 -0
  314. /data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/recovery_lock.rbs +0 -0
  315. /data/sig/{_private/stoplight → stoplight}/infrastructure/memory/storage/recovery_metrics.rbs +0 -0
  316. /data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/metrics.rbs +0 -0
  317. /data/sig/{_private/stoplight → stoplight}/infrastructure/redis/storage/recovery_metrics.rbs +0 -0
  318. /data/sig/{_private/stoplight → stoplight}/infrastructure/system_clock.rbs +0 -0
  319. /data/sig/{_private/stoplight → stoplight}/wiring/data_store_backend.rbs +0 -0
  320. /data/sig/{_private/stoplight → stoplight}/wiring/default_config.rbs +0 -0
  321. /data/sig/{_private/stoplight → stoplight}/wiring/memory/backend.rbs +0 -0
  322. /data/sig/{_private/stoplight → stoplight}/wiring/storage_set.rbs +0 -0
  323. /data/sig/{_private/stoplight → stoplight}/wiring/storage_set_builder.rbs +0 -0
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Stoplight
4
4
  module Wiring
5
- class ConfigurationDsl
5
+ class SystemConfigurationDsl
6
6
  def initialize(
7
- name: T.undefined,
7
+ name,
8
8
  cool_off_time: T.undefined,
9
9
  threshold: T.undefined,
10
10
  recovery_threshold: T.undefined,
@@ -17,15 +17,16 @@ module Stoplight
17
17
  traffic_control: T.undefined,
18
18
  traffic_recovery: T.undefined
19
19
  )
20
- @name = name
20
+ @name = name.to_s
21
+ @id = Domain::Id.for(@name)
21
22
  @cool_off_time = cool_off_time
22
23
  @threshold = threshold
23
24
  @recovery_threshold = recovery_threshold
24
25
  @window_size = window_size
25
- @tracked_errors = tracked_errors
26
- @skipped_errors = skipped_errors
27
- @traffic_control = traffic_control
28
- @traffic_recovery = traffic_recovery
26
+ @tracked_errors = (tracked_errors.is_a?(Undefined) || tracked_errors.is_a?(Array)) ? tracked_errors : [tracked_errors]
27
+ @skipped_errors = (skipped_errors.is_a?(Undefined) || skipped_errors.is_a?(Array)) ? skipped_errors : [skipped_errors]
28
+ @traffic_control = traffic_control.is_a?(Undefined) ? traffic_control : LightConfigurationDsl::TrafficControlDsl.call(traffic_control)
29
+ @traffic_recovery = traffic_recovery.is_a?(Undefined) ? traffic_recovery : LightConfigurationDsl::TrafficRecoveryDsl.call(traffic_recovery)
29
30
  @error_notifier = error_notifier
30
31
  @data_store = data_store
31
32
  @notifiers = notifiers
@@ -34,6 +35,7 @@ module Stoplight
34
35
  def configure!(default_config)
35
36
  ConfigCompatibilityValidator.call(
36
37
  config: default_config.with(
38
+ id: @id,
37
39
  name:,
38
40
  cool_off_time:,
39
41
  threshold:,
@@ -60,42 +62,10 @@ module Stoplight
60
62
  attr_reader :error_notifier
61
63
  attr_reader :data_store
62
64
  attr_reader :notifiers
63
-
64
- def tracked_errors
65
- value = @tracked_errors
66
- if value.is_a?(Undefined)
67
- value
68
- else
69
- Array(value)
70
- end
71
- end
72
-
73
- def skipped_errors
74
- value = @skipped_errors
75
- if value.is_a?(Undefined)
76
- value
77
- else
78
- Array(value)
79
- end
80
- end
81
-
82
- def traffic_control
83
- value = @traffic_control
84
- if value.is_a?(Undefined)
85
- value
86
- else
87
- LightFactory::TrafficControlDsl.call(value)
88
- end
89
- end
90
-
91
- def traffic_recovery
92
- value = @traffic_recovery
93
- if value.is_a?(Undefined)
94
- value
95
- else
96
- LightFactory::TrafficRecoveryDsl.call(value)
97
- end
98
- end
65
+ attr_reader :tracked_errors
66
+ attr_reader :skipped_errors
67
+ attr_reader :traffic_control
68
+ attr_reader :traffic_recovery
99
69
  end
100
70
  end
101
71
  end
data/lib/stoplight.rb CHANGED
@@ -21,13 +21,11 @@ module Stoplight # rubocop:disable Style/Documentation
21
21
 
22
22
  CONFIG_MUTEX = Mutex.new
23
23
  private_constant :CONFIG_MUTEX
24
- @systems = Concurrent::Map.new
25
24
 
26
25
  class << self
27
26
  # Configures the Stoplight library.
28
27
  #
29
28
  # This method allows you to set up the library's configuration using a block.
30
- # It raises an error if called more than once.
31
29
  # @param trust_me_im_an_engineer [Boolean]
32
30
  # @yield [config] Provides a configuration object to the block.
33
31
  # @yieldparam config [Stoplight::Wiring::DefaultConfiguration] The configuration object.
@@ -48,8 +46,7 @@ module Stoplight # rubocop:disable Style/Documentation
48
46
  # it will not be possible to change the configuration of existing circuit breakers. If you do so, the method
49
47
  # produces a warning:
50
48
  #
51
- # "Stoplight reconfigured. Existing circuit breakers will not see the new configuration. New
52
- # configuration: ...f
49
+ # "Stoplight reconfigured. Existing circuit breakers will not see new configuration"
53
50
  #
54
51
  # If you really know what you are doing, you can pass the +trust_me_im_an_engineer+ parameter as +true+ to
55
52
  # suppress this warning, which could be useful in test environments.
@@ -59,86 +56,42 @@ module Stoplight # rubocop:disable Style/Documentation
59
56
  configuration = Wiring::DefaultConfiguration.new
60
57
  yield configuration if block_given?
61
58
 
62
- default_config = configuration.to_config!
63
- @default_config = default_config
64
- @default_light_factory = Wiring::LightFactory.new(config: default_config)
59
+ @state = Wiring::GlobalState.new(default_config: configuration.to_config!)
65
60
  end
66
61
  end
67
62
 
68
- # @api private
69
- def system_light(
70
- name,
71
- cool_off_time: T.undefined,
72
- threshold: T.undefined,
73
- recovery_threshold: T.undefined,
74
- window_size: T.undefined,
75
- tracked_errors: T.undefined,
76
- skipped_errors: T.undefined,
77
- data_store: T.undefined,
78
- error_notifier: T.undefined,
79
- notifiers: T.undefined,
80
- traffic_control: T.undefined,
81
- traffic_recovery: T.undefined
82
- )
83
- Wiring::LightFactory.new(config: Wiring::DefaultConfig).build_with(
84
- name: "__stoplight__#{name}",
85
- cool_off_time:,
86
- threshold:,
87
- recovery_threshold:,
88
- window_size:,
89
- tracked_errors:,
90
- skipped_errors:,
91
- data_store:,
92
- error_notifier:,
93
- notifiers:,
94
- traffic_control:,
95
- traffic_recovery:
96
- )
97
- end
63
+ # Registers a Light with the given configuration.
64
+ #
65
+ # If a light with this name is already registered, returns it. If the given settings
66
+ # differ from the existing registration, raises +Stoplight::Error::ConfigurationError+.
67
+ # #
68
+ # @example
69
+ # Stoplight.register("stripe", threshold: 5, cool_off_time: 60)
70
+ #
71
+ def register(...) = state.default_system.register(...)
98
72
 
99
- # Create a Light with the user default configuration.
73
+ # Returns a Light previously registered.
100
74
  #
101
- # @return [Stoplight::Light]
102
- # @api private
103
- def light(
104
- name,
105
- cool_off_time: T.undefined,
106
- threshold: T.undefined,
107
- recovery_threshold: T.undefined,
108
- window_size: T.undefined,
109
- tracked_errors: T.undefined,
110
- skipped_errors: T.undefined,
111
- data_store: T.undefined,
112
- error_notifier: T.undefined,
113
- notifiers: T.undefined,
114
- traffic_control: T.undefined,
115
- traffic_recovery: T.undefined
116
- )
117
- __stoplight__default_light_factory.build_with(
118
- name:,
119
- cool_off_time:,
120
- threshold:,
121
- recovery_threshold:,
122
- window_size:,
123
- tracked_errors:,
124
- skipped_errors:,
125
- data_store:,
126
- error_notifier:,
127
- notifiers:,
128
- traffic_control:,
129
- traffic_recovery:
130
- )
131
- end
75
+ # @raise [Stoplight::Error::UnregisteredLightError] if no light was registered under +name+
76
+ #
77
+ # @example
78
+ # Stoplight.register("stripe", threshold: 5)
79
+ # Stoplight.light("stripe")
80
+ #
81
+ def light(...) = state.default_system.light(...)
82
+
83
+ # Returns the consumer side of the default system's telemetry bus.
84
+ #
85
+ # @example
86
+ # Stoplight.telemetry.subscribe(Stoplight::Telemetry::RunCompleted) { |envelope| track(envelope) }
87
+ #
88
+ def telemetry = state.default_system.telemetry
132
89
 
133
90
  # Creates a new named system with the given configuration.
134
91
  #
135
92
  # Systems are composition roots that own infrastructure (data store, notifiers)
136
93
  # and enforce configuration consistency for all lights created within them.
137
94
  #
138
- # @param name [String] Unique identifier for the system
139
- # @param settings [Hash] Configuration options that override global defaults.
140
- # @see Stoplight() documentation
141
- #
142
95
  # @return [Stoplight::Wiring::System] A new system instance.
143
96
  #
144
97
  # @raise [ArgumentError] If a system with the given name already exists.
@@ -147,55 +100,14 @@ module Stoplight # rubocop:disable Style/Documentation
147
100
  # for repeated access. Calling this method twice with the same name raises an error.
148
101
  #
149
102
  # @example Creating a system for payment services
150
- # Payments = Stoplight.__stoplight__system(:payments, threshold: 3, cool_off_time: 30)
103
+ # Payments = Stoplight.register_system("Payments", threshold: 3, cool_off_time: 30)
104
+ # Payments.register("stripe")
151
105
  # Payments.light("stripe").run { process_payment }
152
106
  #
153
107
  # @example Isolated system with dedicated data store
154
- # Analytics = Stoplight.__stoplight__system(:analytics, data_store: analytics_redis)
108
+ # Analytics = Stoplight.register_system("Analytics", data_store: analytics_redis)
155
109
  #
156
- # @api private
157
- def __stoplight__system(
158
- name,
159
- cool_off_time: T.undefined,
160
- threshold: T.undefined,
161
- recovery_threshold: T.undefined,
162
- window_size: T.undefined,
163
- tracked_errors: T.undefined,
164
- skipped_errors: T.undefined,
165
- data_store: T.undefined,
166
- error_notifier: T.undefined,
167
- notifiers: T.undefined,
168
- traffic_control: T.undefined,
169
- traffic_recovery: T.undefined
170
- )
171
- ensure_configured
172
-
173
- systems.compute(name.to_s) do |existing_system|
174
- if existing_system
175
- raise ArgumentError, "system `#{name}` is already in use"
176
- else
177
- Wiring::System.new(
178
- config: Wiring::ConfigurationDsl.new(
179
- name: name.to_s,
180
- cool_off_time:,
181
- threshold:,
182
- recovery_threshold:,
183
- window_size:,
184
- tracked_errors:,
185
- skipped_errors:,
186
- traffic_control:,
187
- traffic_recovery:,
188
- data_store:,
189
- error_notifier:,
190
- notifiers:
191
- ).configure!(default_config)
192
- )
193
- end
194
- end
195
- end
196
-
197
- private attr_reader :systems
198
- private def default_config = T.must(@default_config)
110
+ def register_system(...) = state.register_system(...)
199
111
 
200
112
  # Resets Stoplight to an unconfigured state.
201
113
  #
@@ -221,28 +133,16 @@ module Stoplight # rubocop:disable Style/Documentation
221
133
  #
222
134
  # @api private
223
135
  def __stoplight__reset!
224
- @systems = Concurrent::Map.new
225
- @default_config = nil
226
- @default_light_factory = nil
227
- @configured = nil
228
- end
229
-
230
- # Retrieves the current default dependencies.
231
- #
232
- # @return [Stoplight::Domain::LightFactory]
233
- # @api private
234
- def __stoplight__default_light_factory
235
- ensure_configured
236
- T.must(@default_light_factory)
136
+ @state = nil
237
137
  end
238
138
 
239
- def __stoplight__default_configuration
240
- ensure_configured
241
- T.must(@default_config)
242
- end
139
+ def __stoplight__default_configuration = state.default_config
140
+ def __stoplight__default_system = state.default_system
243
141
 
244
142
  # @api private
245
143
  private def ensure_configured
144
+ return if configured?
145
+
246
146
  CONFIG_MUTEX.synchronize do
247
147
  configure unless configured?
248
148
  end
@@ -253,38 +153,36 @@ module Stoplight # rubocop:disable Style/Documentation
253
153
  warn "Stoplight reconfigured. Existing circuit breakers will not see new configuration"
254
154
  end
255
155
  yield
256
- @configured = true
257
156
  end
258
157
 
259
158
  private def configured?
260
- @configured == true
159
+ @state != nil
160
+ end
161
+
162
+ private def state
163
+ ensure_configured
164
+ T.must(@state)
261
165
  end
262
166
  end
263
167
  end
264
168
 
265
- # Creates a new Stoplight circuit brNeaker with the given name and settings.
169
+ # Creates a new Stoplight circuit breaker with the given name and settings.
266
170
  #
267
171
  # @param name [String] The name of the circuit breaker.
268
- # @param settings [Hash] Optional settings to configure the circuit breaker.
269
- # @option settings [Numeric] :cool_off_time The time to wait before resetting the circuit breaker.
270
- # @option settings [Stoplight::DataStore::Base] :data_store The data store to use for storing state.
271
- # @option settings [Array<Stoplight::Notifier::Base>] :notifiers A list of notifiers to use.
272
- # @option settings [Numeric] :threshold The failure threshold to trip the circuit breaker.
273
- # @option settings [Numeric] :window_size The size of the rolling window for failure tracking.
274
- # @option settings [Array<StandardError>] :tracked_errors A list of errors to track.
275
- # @option settings [Array<Exception>] :skipped_errors A list of errors to skip.
276
- # @option settings [Symbol, {Symbol, Hash{Symbol, any}}] :traffic_control The
277
- # traffic control strategy to use.
172
+ # @param cool_off_time The time to wait before resetting the circuit breaker, in whole seconds, at least 1.
173
+ # @param threshold The failure threshold to trip the circuit breaker.
174
+ # @param window_size The size of the rolling window for failure tracking, in whole seconds, at least 1.
175
+ # @param tracked_errors A list of errors to track.
176
+ # @param skipped_errors A list of errors to skip.
177
+ # @param traffic_control The traffic control strategy to use.
278
178
  #
279
179
  # @return [Stoplight::Light] A new circuit breaker instance.
280
180
  # @raise [ArgumentError] If an unknown option is provided in the settings.
181
+ # @raise [Stoplight::Error::ConfigurationError] If a setting is invalid or conflicts with an earlier registration.
281
182
  #
282
183
  # @example configure circuit breaker behavior
283
184
  # light = Stoplight("Payment API", window_size: 300, threshold: 5, cool_off_time: 60)
284
185
  #
285
- # @example configure data store
286
- # light = Stoplight("Payment API", data_store: Stoplight::DataStore::Redis.new(redis_client))
287
- #
288
186
  # In the example below, the +TimeoutError+ and +NetworkError+ exceptions
289
187
  # will be counted towards the threshold for moving the circuit breaker into the red state.
290
188
  # If not configured, the default tracked error is +StandardError+.
@@ -306,46 +204,4 @@ end
306
204
  # # When 66.6% error rate reached withing a sliding 5 minute window, the circuit breaker will trip.
307
205
  # light = Stoplight("Payment API", traffic_control: :error_rate, threshold: 0.666, window_size: 300)
308
206
  #
309
- def Stoplight(
310
- name,
311
- cool_off_time: Stoplight::T.undefined,
312
- threshold: Stoplight::T.undefined,
313
- recovery_threshold: Stoplight::T.undefined,
314
- window_size: Stoplight::T.undefined,
315
- tracked_errors: Stoplight::T.undefined,
316
- skipped_errors: Stoplight::T.undefined,
317
- data_store: Stoplight::T.undefined,
318
- error_notifier: Stoplight::T.undefined,
319
- notifiers: Stoplight::T.undefined,
320
- traffic_control: Stoplight::T.undefined,
321
- traffic_recovery: Stoplight::T.undefined
322
- ) # rubocop:disable Naming/MethodName
323
- Stoplight::Common::Deprecations.deprecate(<<~MSG) if error_notifier != Stoplight::T.undefined
324
- Passing "error_notifier" to Stoplight('#{name}') is deprecated and will be removed in v6.0.0.
325
-
326
- IMPORTANT: The `error_notifier` is NOT called for exceptions in your protected code.
327
- It only reports internal Stoplight failures (e.g., Redis connection errors).
328
-
329
- To fix: Move `error_notifier` to global configuration:
330
-
331
- Stoplight.configure do |config|
332
- config.error_notifier = ->(error) { Logger.warn(error) }
333
- end
334
-
335
- See: https://github.com/bolshakov/stoplight#error-notifiers
336
- MSG
337
- Stoplight.light(
338
- name,
339
- cool_off_time:,
340
- threshold:,
341
- recovery_threshold:,
342
- window_size:,
343
- tracked_errors:,
344
- skipped_errors:,
345
- data_store:,
346
- error_notifier:,
347
- notifiers:,
348
- traffic_control:,
349
- traffic_recovery:
350
- )
351
- end
207
+ def Stoplight(...) = Stoplight.register(...) # rubocop:disable Naming/MethodName
@@ -0,0 +1,6 @@
1
+ module Sinatra
2
+ class Base
3
+ # TODO: temporarily fix https://github.com/ruby/gem_rbs_collection/pull/1057
4
+ def erb: (untyped template, ?::Hash[untyped, untyped] options, ?::Hash[untyped, untyped] locals) ?{ () -> untyped } -> untyped
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module SecureRandom
2
+ def self.uuid: () -> String
3
+ def self.hex: (Integer) -> String
4
+ end
@@ -0,0 +1,10 @@
1
+
2
+ module Stoplight
3
+ class Admin
4
+ module Actions
5
+ class Action
6
+ def halt: (Integer status) -> void
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module Stoplight
2
+ class Admin
3
+ module Actions
4
+ class Lock < Action
5
+ @config_registry: ConfigRegistry
6
+ @storage: Wiring::System::Storage
7
+
8
+ def initialize: (
9
+ config_registry: ConfigRegistry,
10
+ storage: Wiring::System::Storage
11
+ ) -> void
12
+
13
+ def call: (light_id: String, color: Domain::color) -> void
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Stoplight
2
+ class Admin
3
+ module Actions
4
+ class LockAll < Action
5
+ @config_registry: ConfigRegistry
6
+ @storage: Wiring::System::Storage
7
+
8
+ def initialize: (
9
+ config_registry: ConfigRegistry,
10
+ storage: Wiring::System::Storage
11
+ ) -> void
12
+
13
+ def call: (color: Domain::color)-> void
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stoplight
4
+ class Admin
5
+ module Actions
6
+ # This action removes a light's metadata from Redis
7
+ class Remove < Action
8
+ @config_registry: ConfigRegistry
9
+ @storage: Wiring::System::Storage
10
+ @registry: Domain::_Registry
11
+
12
+ def initialize: (
13
+ config_registry: ConfigRegistry,
14
+ storage: Wiring::System::Storage,
15
+ registry: Domain::_Registry
16
+ ) -> void
17
+
18
+ def call: (light_id: String) -> void
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stoplight
4
+ class Admin
5
+ module Actions
6
+ class Stats < Action
7
+ @lights_stats: singleton(Stoplight::Admin::LightsStats)
8
+ @config_registry: ConfigRegistry
9
+ @storage: Wiring::System::Storage
10
+
11
+ # @param lights_stats [Class<Stoplight::Admin::LightsStats>]
12
+ def initialize: (
13
+ lights_stats: singleton(Stoplight::Admin::LightsStats),
14
+ config_registry: ConfigRegistry,
15
+ storage: Wiring::System::Storage,
16
+ ) -> void
17
+
18
+ # @return [(Stoplight::Admin::LightView)]
19
+ def call: -> [
20
+ Array[LightView],
21
+ Hash[Symbol, Integer],
22
+ ]
23
+
24
+ private def build_light: (Domain::Config) -> LightView
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ module Stoplight
2
+ class Admin
3
+ module Actions
4
+ class Unlock < Action
5
+ @config_registry: ConfigRegistry
6
+ @storage: Wiring::System::Storage
7
+
8
+ def initialize: (
9
+ config_registry: ConfigRegistry,
10
+ storage: Wiring::System::Storage
11
+ ) -> void
12
+
13
+ def call: (light_id: String) -> void
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ module Stoplight
2
+ class Admin
3
+ class ConfigRegistry
4
+ @registry: Domain::_Registry
5
+ @system_config: Domain::Config
6
+
7
+ def initialize: (
8
+ registry: Domain::_Registry,
9
+ system_config: Domain::Config
10
+ ) -> void
11
+
12
+ def all: -> Array[Domain::Config]
13
+ def find_by_id: (String) -> Domain::Config?
14
+
15
+ private
16
+
17
+ def deserialize_config: (Hash[String, untyped]) -> Domain::Config
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ module Stoplight
2
+ class Admin
3
+ class Dependencies
4
+ @system: Wiring::System
5
+ @storage: Wiring::System::Storage
6
+
7
+ def initialize: (system: Wiring::System) -> void
8
+ def config_registry: -> ConfigRegistry
9
+ def stats_action: -> Actions::Stats
10
+ def unlock_action: -> Actions::Unlock
11
+ def lock_action: -> Actions::Lock
12
+ def lock_all_action: -> Actions::LockAll
13
+ def remove_action: -> Actions::Remove
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Stoplight
2
+ class Admin
3
+ module Helpers : Sinatra::Base
4
+ COLORS: Array[Domain::color]
5
+
6
+ def dependencies: -> Dependencies
7
+ def system_url: (String system_id, String path) -> String
8
+ def asset_path: (String) -> String
9
+ def time_ago_in_words: (Time) -> String
10
+ def control_attributes: (String href, ?confirm: String?, ?verb: String?) -> String
11
+ def find_system: (String) -> Wiring::System
12
+ def current_system_id: -> String
13
+ def current_system: -> Wiring::System
14
+ def show_system_switcher?: -> bool
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ module Stoplight
2
+ class Admin
3
+ class LightView
4
+ COLORS: Array[Domain::color]
5
+
6
+ attr_reader failures: Array[Domain::Failure]
7
+
8
+ @state_snapshot: Domain::StateSnapshot
9
+ @metrics_snapshot: Domain::MetricsSnapshot
10
+ @recovery_metrics_snapshot: Domain::MetricsSnapshot
11
+ @config: Domain::Config
12
+ @failures: Array[Domain::Failure]
13
+
14
+ def initialize: (
15
+ config: Domain::Config,
16
+ state_snapshot: Domain::StateSnapshot,
17
+ recovery_metrics_snapshot: Domain::MetricsSnapshot,
18
+ metrics_snapshot: Domain::MetricsSnapshot,
19
+ ) -> void
20
+
21
+ def id: -> String
22
+ def color: -> Domain::color
23
+ def name: -> String
24
+ def state: -> Domain::state
25
+ def traffic_metric_label: -> String
26
+ def traffic_metric_value: -> String
27
+ def locked?: -> bool
28
+ def unlocked?: -> bool
29
+ def as_json: -> Hash[Symbol, _ToS]
30
+ def default_sort_key: -> Array[Comparable]
31
+ def last_check: -> Time?
32
+ private def duration_in_words: (Integer) -> String
33
+ def description_title: -> String
34
+ def description_message: -> String
35
+ def description_comment: -> String
36
+ def latest_failure: -> Domain::Failure?
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,30 @@
1
+ module Stoplight
2
+ class Admin
3
+ class LightsStats
4
+ EMPTY_STATS: Hash[Symbol, Integer]
5
+
6
+ attr_reader lights: Array[LightView]
7
+ @lights: Array[LightView]
8
+
9
+ def self.call: (Array[LightView]) -> Hash[Symbol, Integer]
10
+
11
+ def initialize: (Array[LightView]) -> void
12
+
13
+ def call: -> Hash[Symbol, Integer]
14
+
15
+ private
16
+
17
+ def size: -> Integer
18
+
19
+ def count_lights: (Domain::color)-> Integer
20
+ def count_red: -> Integer
21
+ def count_green: -> Integer
22
+ def count_yellow: -> Integer
23
+
24
+ def percent_lights: (Domain::color)-> Integer
25
+ def percent_green: -> Integer
26
+ def percent_red: -> Integer
27
+ def percent_yellow: -> Integer
28
+ end
29
+ end
30
+ end