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
@@ -0,0 +1,14 @@
1
+ module Stoplight
2
+ class Admin < Sinatra::Base
3
+ COLORS: Array[Domain::color]
4
+ ASSETS_PATH: String
5
+ ASSET_DIGESTS: Hash[String, String]
6
+ ONE_YEAR_IN_SECONDS: Integer
7
+ include Helpers
8
+
9
+ self.@systems: Array[Wiring::System]
10
+ def self.add_system: (Wiring::System) -> void
11
+ def self.__stoplight__reset_systems!: -> void
12
+ def self.validate_persistent_system!: (Wiring::System) -> Wiring::System
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module Stoplight
2
2
  module Color
3
- GREEN: green
4
- YELLOW: yellow
5
- RED: red
3
+ GREEN: Domain::green
4
+ YELLOW: Domain::yellow
5
+ RED: Domain::red
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  module Stoplight
2
2
  module DataStore
3
+ # @api private
3
4
  class Base
4
5
  end
5
6
  end
@@ -0,0 +1,9 @@
1
+ module Stoplight
2
+ module DataStore
3
+ # Configuration for Memory-backed Stoplight storage.
4
+ #
5
+ # @note This is a configuration object, not the storage implementation itself.
6
+ class Memory < Base
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ module Stoplight
2
+ module DataStore
3
+ # Configuration for Redis-backed Stoplight storage.
4
+ #
5
+ # @note This is a configuration object, not the storage implementation itself.
6
+ class Redis < Base
7
+ KEY_SPACE: Infrastructure::Redis::Key
8
+
9
+ attr_reader redis: Infrastructure::redis
10
+
11
+ def initialize: (Infrastructure::redis) -> void
12
+
13
+ def self.key_space: -> Infrastructure::Redis::Key
14
+ def key_space: -> Infrastructure::Redis::Key
15
+ end
16
+ end
17
+ end
@@ -1,64 +1,68 @@
1
1
  module Stoplight
2
2
  module Domain
3
3
  class Config < Data
4
+ attr_reader id: String
4
5
  attr_reader threshold: percentage | Integer
5
- attr_reader window_size: duration?
6
- attr_reader tracked_errors: Array[_ExceptionMatcher]
7
- attr_reader skipped_errors: Array[_ExceptionMatcher]
6
+ attr_reader window_size: duration_seconds?
7
+ attr_reader tracked_errors: Array[Module]
8
+ attr_reader skipped_errors: Array[Module]
8
9
  attr_reader name: String
9
- attr_reader cool_off_time: duration
10
+ attr_reader cool_off_time: duration_seconds
10
11
  attr_reader recovery_threshold: Integer
11
12
  attr_reader traffic_control: _TrafficControl
12
13
  attr_reader traffic_recovery: _TrafficRecovery
13
14
  attr_reader error_notifier: error_notifier
14
- attr_reader notifiers: Array[state_transition_notifier]
15
- attr_reader data_store: data_store
15
+ attr_reader notifiers: Array[_StateTransitionNotifier]
16
+ attr_reader data_store: _DataStore
16
17
 
17
18
  def self.new: (
19
+ id: String,
18
20
  name: String,
19
- cool_off_time: duration,
21
+ cool_off_time: duration_seconds,
20
22
  threshold: percentage | Integer,
21
23
  recovery_threshold: Integer,
22
- window_size: duration?,
23
- tracked_errors: Array[_ExceptionMatcher],
24
- skipped_errors: Array[_ExceptionMatcher],
24
+ window_size: duration_seconds?,
25
+ tracked_errors: Array[Module],
26
+ skipped_errors: Array[Module],
25
27
  traffic_control: _TrafficControl,
26
28
  traffic_recovery: _TrafficRecovery,
27
29
  error_notifier: error_notifier,
28
- notifiers: Array[state_transition_notifier],
29
- data_store: data_store
30
+ notifiers: Array[_StateTransitionNotifier],
31
+ data_store: _DataStore
30
32
  ) -> instance
31
33
 
32
34
  def initialize: (
35
+ id: String,
33
36
  name: String,
34
- cool_off_time: duration,
37
+ cool_off_time: duration_seconds,
35
38
  threshold: percentage | Integer,
36
39
  recovery_threshold: Integer,
37
- window_size: duration?,
38
- tracked_errors: Array[_ExceptionMatcher],
39
- skipped_errors: Array[_ExceptionMatcher],
40
+ window_size: duration_seconds?,
41
+ tracked_errors: Array[Module],
42
+ skipped_errors: Array[Module],
40
43
  traffic_control: _TrafficControl,
41
44
  traffic_recovery: _TrafficRecovery,
42
45
  error_notifier: error_notifier,
43
- notifiers: Array[state_transition_notifier],
44
- data_store: data_store
46
+ notifiers: Array[_StateTransitionNotifier],
47
+ data_store: _DataStore
45
48
  ) -> void
46
49
 
47
50
  def cool_off_time_in_milliseconds: () -> Integer
48
51
 
49
52
  def with: (
53
+ ?id: optional[String],
50
54
  ?name: optional[String],
51
- ?cool_off_time: optional[duration],
55
+ ?cool_off_time: optional[duration_seconds],
52
56
  ?threshold: optional[percentage | Integer],
53
57
  ?recovery_threshold: optional[Integer],
54
- ?window_size: optional[duration?],
55
- ?tracked_errors: optional[Array[_ExceptionMatcher]],
56
- ?skipped_errors: optional[Array[_ExceptionMatcher]],
58
+ ?window_size: optional[duration_seconds?],
59
+ ?tracked_errors: optional[Array[Module]],
60
+ ?skipped_errors: optional[Array[Module]],
57
61
  ?traffic_control: optional[_TrafficControl],
58
62
  ?traffic_recovery: optional[_TrafficRecovery],
59
63
  ?error_notifier: optional[error_notifier],
60
- ?notifiers: optional[Array[state_transition_notifier]],
61
- ?data_store: optional[data_store],
64
+ ?notifiers: optional[Array[_StateTransitionNotifier]],
65
+ ?data_store: optional[_DataStore],
62
66
  ) -> Config | () -> Config
63
67
  end
64
68
  end
@@ -5,6 +5,10 @@ module Stoplight
5
5
  @skipped: Array[_ExceptionMatcher]
6
6
 
7
7
  def initialize: (tracked: Array[_ExceptionMatcher], skipped: Array[_ExceptionMatcher]) -> void
8
+ def with: (
9
+ ?tracked: optional[Array[_ExceptionMatcher] | _ExceptionMatcher],
10
+ ?skipped: optional[Array[_ExceptionMatcher] | _ExceptionMatcher]
11
+ ) -> ErrorTrackingPolicy
8
12
  def track?: (StandardError) -> bool
9
13
 
10
14
  def skipped?: (StandardError) -> bool
@@ -11,6 +11,8 @@ module Stoplight
11
11
  def initialize: (String error_class, String error_message, Time time) -> void
12
12
 
13
13
  def ==: (untyped other) -> bool
14
+ def eql?: (untyped other) -> bool
15
+ def hash: () -> Integer
14
16
  end
15
17
  end
16
18
  end
@@ -0,0 +1,7 @@
1
+ module Stoplight
2
+ module Domain
3
+ module Id
4
+ def self.for: (String) -> String
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,39 @@
1
+ module Stoplight
2
+ module Domain
3
+ class Light
4
+ attr_reader name: String
5
+ attr_reader green_run_strategy: Strategies::GreenRunStrategy
6
+ attr_reader yellow_run_strategy: Strategies::YellowRunStrategy
7
+ attr_reader red_run_strategy: Strategies::RedRunStrategy
8
+ attr_reader state_store: _StateStore
9
+
10
+ @name: String
11
+ @lock_control: LockControl
12
+ @error_tracking_policy: ErrorTrackingPolicy
13
+
14
+ def initialize: (
15
+ String name,
16
+ green_run_strategy: Strategies::GreenRunStrategy,
17
+ yellow_run_strategy: Strategies::YellowRunStrategy,
18
+ red_run_strategy: Strategies::RedRunStrategy,
19
+ state_store: _StateStore,
20
+ lock_control: LockControl,
21
+ error_tracking_policy: ErrorTrackingPolicy
22
+ ) -> void
23
+
24
+ def state: -> Domain::state
25
+ def color: -> Domain::color
26
+ def run: [T] (
27
+ ?(^(StandardError?) -> T)?,
28
+ ?tracked_errors: optional[Array[Domain::_ExceptionMatcher] | Domain::_ExceptionMatcher],
29
+ ?skipped_errors: optional[Array[Domain::_ExceptionMatcher] | Domain::_ExceptionMatcher]
30
+ ) { () -> T } -> T
31
+ def lock: (Domain::color) -> Light
32
+ def unlock: -> Light
33
+
34
+ private
35
+ def state_strategy_factory: (color) -> _RunStrategy
36
+ def state_snapshot: -> StateSnapshot
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,7 @@
1
1
  module Stoplight
2
2
  module Domain
3
3
  class LightInfo < Data
4
- include _LightInfo
4
+ attr_reader name: String
5
5
 
6
6
  def self.new: (
7
7
  name: String,
@@ -10,10 +10,6 @@ module Stoplight
10
10
  def initialize: (
11
11
  name: String,
12
12
  ) -> void
13
-
14
- def with: (
15
- ?name: String,
16
- ) -> LightInfo
17
13
  end
18
14
  end
19
15
  end
@@ -0,0 +1,16 @@
1
+ module Stoplight
2
+ module Domain
3
+ class LockControl
4
+ @state_store: _StateStore
5
+ @emitter: Telemetry::Emitter
6
+
7
+ def initialize: (
8
+ state_store: _StateStore,
9
+ emitter: Telemetry::Emitter
10
+ ) -> void
11
+
12
+ def lock: (color) -> void
13
+ def unlock: -> void
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module Stoplight
2
+ module Domain
3
+ class MatcherValidator
4
+ def self.call: (Module) -> String
5
+
6
+ private
7
+
8
+ def self.message: (Module) -> String
9
+ end
10
+ end
11
+ end
@@ -11,6 +11,12 @@ module Stoplight
11
11
  # Returns the current time.
12
12
  def current_time: () -> Time
13
13
 
14
+ # Returns monotonic time in ms
15
+ def monotonic_millis: () -> Float
16
+
17
+ # Returns monotonic time in s
18
+ def monotonic_seconds: () -> Float
19
+
14
20
  # Converts a Unix timestamp to a Time object.
15
21
  def at: (timestamp) -> Time
16
22
  end
@@ -0,0 +1,9 @@
1
+ module Stoplight
2
+ module Domain
3
+ # Data store configuration, specifies which data store should be
4
+ # used to store Stoplight state
5
+ interface _DataStore
6
+ def is_a?: (untyped klass) -> bool
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module Stoplight
2
+ module Domain
3
+ # Called when Stoplight internals fail (e.g. Redis unavailable, notifier I/O).
4
+ interface _ErrorNotifier
5
+ def call: (StandardError) -> void
6
+
7
+ # Object methods
8
+ def ==: (untyped) -> bool
9
+ def is_a?: (untyped) -> bool
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Stoplight
2
+ module Domain
3
+ interface _ExceptionMatcher
4
+ def ===: (untyped) -> bool
5
+
6
+ # Object methods
7
+ def is_a?: (untyped) -> bool
8
+ end
9
+ end
10
+ end
@@ -19,8 +19,8 @@ module Stoplight
19
19
  # Records a successful circuit breaker execution
20
20
  def record_success: () -> void
21
21
 
22
- # Records a failed circuit breaker execution
23
- def record_failure: (StandardError error) -> void
22
+ # Records a failed circuit breaker execution and returns the resulting snapshot
23
+ def record_failure: (StandardError error) -> Domain::MetricsSnapshot
24
24
 
25
25
  # Clears all metrics for this circuit
26
26
  def clear: () -> void
@@ -0,0 +1,13 @@
1
+ module Stoplight
2
+ module Domain
3
+ # Holds the information about existing lights.
4
+ # Each system has its own registry so you can query lights belonging to it.
5
+ interface _Registry
6
+ def ids: -> Array[String]
7
+ def register: (Config) -> void
8
+ def unregister: (String id) -> void
9
+ def config_for: (String id) -> Hash[String, untyped]?
10
+ def all_configs: -> Array[Hash[String, untyped]]
11
+ end
12
+ end
13
+ end
@@ -7,7 +7,8 @@ module Stoplight
7
7
  # @param fallback A fallback proc to execute in case of an error.
8
8
  def execute: [T] (
9
9
  (^(StandardError?) -> T)? fallback,
10
- state_snapshot: StateSnapshot
10
+ state_snapshot: StateSnapshot,
11
+ error_tracking_policy: ErrorTrackingPolicy
11
12
  ) { () -> T } -> T
12
13
  end
13
14
  end
@@ -0,0 +1,18 @@
1
+ module Stoplight
2
+ module Domain
3
+ interface _StateTransitionNotifier
4
+ # Sends a notification when a Stoplight changes state.
5
+ #
6
+ # @param light The Stoplight instance triggering the notification.
7
+ # @param from_color The previous state color of the Stoplight.
8
+ # @param to_color The new state color of the Stoplight.
9
+ # @param error The error (if any) that caused the state change.
10
+ def notify: (Domain::LightInfo, Domain::color from_color, Domain::color to_color, ?StandardError? error) -> void
11
+
12
+ # Object methods needed for comparison/inspection
13
+ def ==: (untyped) -> bool
14
+
15
+ def class: -> Class
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ module Stoplight
2
+ module Domain
3
+ # Consumer-facing side of the telemetry bus: subscription only. The producer side is internal
4
+ # (see Domain::_TelemetryPublisher). This is what +_System#telemetry+ returns.
5
+ interface _Telemetry
6
+ # Supports the following variants:
7
+ # - Firehose (no filter): every event, including types added in future versions - filter by payload class
8
+ # (+case envelope.payload+ narrows the union).
9
+ # - Filtered by event class: only that event, with the envelope's payload pre-narrowed.
10
+ # - Filtered by +StateTransitioned+: the closed transition union - the complete color timeline.
11
+ #
12
+ # @raise [Stoplight::Error::TooManySubscriptions] if the bus's subscription cap is reached.
13
+ def subscribe: () { (Telemetry::Envelope[Telemetry::event]) -> void } -> Telemetry::Subscription
14
+ | (singleton(Telemetry::RunCompleted)) { (Telemetry::Envelope[Telemetry::RunCompleted]) -> void } -> Telemetry::Subscription
15
+ | (singleton(Telemetry::TrafficBreached)) { (Telemetry::Envelope[Telemetry::TrafficBreached]) -> void } -> Telemetry::Subscription
16
+ | (singleton(Telemetry::RecoveryStarted)) { (Telemetry::Envelope[Telemetry::RecoveryStarted]) -> void } -> Telemetry::Subscription
17
+ | (singleton(Telemetry::RecoverySucceeded)) { (Telemetry::Envelope[Telemetry::RecoverySucceeded]) -> void } -> Telemetry::Subscription
18
+ | (singleton(Telemetry::RecoveryFailed)) { (Telemetry::Envelope[Telemetry::RecoveryFailed]) -> void } -> Telemetry::Subscription
19
+ | (singleton(Telemetry::LockChanged)) { (Telemetry::Envelope[Telemetry::LockChanged]) -> void } -> Telemetry::Subscription
20
+ | (singleton(Telemetry::RecoveryProbeCompleted)) { (Telemetry::Envelope[Telemetry::RecoveryProbeCompleted]) -> void } -> Telemetry::Subscription
21
+ | (singleton(Telemetry::LightRegistered)) { (Telemetry::Envelope[Telemetry::LightRegistered]) -> void } -> Telemetry::Subscription
22
+ | (singleton(Telemetry::StateTransitioned)) { (Telemetry::Envelope[Telemetry::state_transitioned]) -> void } -> Telemetry::Subscription
23
+
24
+ # Idempotent: removing an already-removed or unknown token is a no-op.
25
+ def unsubscribe: (Telemetry::Subscription) -> void
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ module Stoplight
2
+ module Domain
3
+ # Producer-facing side of the telemetry bus, injected into Telemetry::Emitter. End users never
4
+ # see it: they get the consumer side (_Telemetry) from +_System#telemetry+.
5
+ interface _TelemetryPublisher
6
+ # True when any subscriber (firehose, exact class, or via the StateTransitioned marker) would
7
+ # receive this event class. The Emitter guards on it before building anything.
8
+ def subscribed?: (Telemetry::event_class) -> bool
9
+
10
+ # Delivers to every interested subscriber, synchronously, in subscription order.
11
+ def publish: (Telemetry::Envelope[Telemetry::event]) -> void
12
+ end
13
+ end
14
+ end
@@ -22,6 +22,10 @@ module Stoplight
22
22
  # error_rate = metrics.failures.fdiv(total)
23
23
  # error_rate >= 0.5 # Stop traffic when error rate reaches 50%
24
24
  # end
25
+ #
26
+ # def name
27
+ # "error_rate_custom"
28
+ # end
25
29
  # end
26
30
  #
27
31
  interface _TrafficControl
@@ -33,6 +37,9 @@ module Stoplight
33
37
  # @return +true+ if traffic should be stopped otherwise false
34
38
  def stop_traffic?: (Config, Domain::MetricsSnapshot) -> bool
35
39
 
40
+ # Returns a string identifier for this policy (e.g. "consecutive_errors", "error_rate").
41
+ def name: () -> String
42
+
36
43
  # Object methods
37
44
  def ==: (untyped) -> bool
38
45
  def is_a?: (untyped) -> bool
@@ -1,7 +1,5 @@
1
1
  module Stoplight
2
2
  module Domain
3
- type decision = :green | :yellow | :red
4
-
5
3
  # Strategies for determining how to recover traffic flow through the Stoplight.
6
4
  # These strategies evaluate recovery metrics to decide which color the Stoplight should
7
5
  # transition to during the recovery process.
@@ -37,11 +35,12 @@ module Stoplight
37
35
 
38
36
  # Determines the appropriate recovery state based on the Stoplight's
39
37
  # current metrics and recovery progress.
40
- def determine_color: (Config, Domain::MetricsSnapshot) -> decision
38
+ def determine_color: (Config, Domain::MetricsSnapshot) -> recovery_decision
41
39
 
42
40
  # Object methods
43
41
  def ==: (untyped) -> bool
44
42
  def is_a?: (untyped) -> bool
43
+ def name: -> String
45
44
  end
46
45
  end
47
46
  end
@@ -0,0 +1,22 @@
1
+ module Stoplight
2
+ module Domain
3
+ module Strategies
4
+ class GreenRunStrategy
5
+ include _RunStrategy
6
+
7
+ attr_reader request_tracker: Tracker::Request
8
+ @run_recorder: Telemetry::RunRecorder
9
+ @clock: _Clock
10
+
11
+ def initialize: (request_tracker: Tracker::Request,
12
+ run_recorder: Telemetry::RunRecorder, clock: _Clock) -> void
13
+
14
+ def capture_started_at: () -> Float?
15
+ def duration_since: (Float?) -> duration_ms?
16
+
17
+ def record_error: (StandardError, duration_ms: duration_ms?, fallback_used: bool) -> void
18
+ def record_success: (duration_ms: duration_ms?, ?error: StandardError?)-> void
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ module Stoplight
2
+ module Domain
3
+ module Strategies
4
+ class RedRunStrategy
5
+ include _RunStrategy
6
+
7
+ @name: String
8
+ @cool_off_time: duration_seconds
9
+ @run_recorder: Telemetry::RunRecorder
10
+
11
+ def initialize: (
12
+ name: String,
13
+ cool_off_time: duration_seconds,
14
+ run_recorder: Telemetry::RunRecorder,
15
+ ) -> void
16
+ end
17
+ end
18
+ end
19
+ end
@@ -7,34 +7,45 @@ module Stoplight
7
7
  attr_reader state_store: Domain::_StateStore
8
8
  attr_reader metrics_store: _MetricsStore
9
9
  attr_reader recovery_lock_store: _RecoveryLockStore
10
- attr_reader notifiers: Array[state_transition_notifier]
11
10
  attr_reader request_tracker: Tracker::RecoveryProbe
12
- attr_reader red_run_strategy: RedRunStrategy
13
11
 
14
12
  @name: String
15
13
  @config: Domain::Config
16
- @error_tracking_policy: ErrorTrackingPolicy
14
+ @clock: _Clock
15
+ @run_recorder: Telemetry::RunRecorder
16
+ @emitter: Telemetry::Emitter
17
17
 
18
18
  def initialize: (
19
19
  name: String,
20
- error_tracking_policy: ErrorTrackingPolicy,
21
- notifiers: Array[state_transition_notifier],
22
20
  request_tracker: Tracker::RecoveryProbe,
23
- red_run_strategy: RedRunStrategy,
24
- state_store: Domain::_StateStore,
21
+ state_store: _StateStore,
25
22
  metrics_store: _MetricsStore,
26
23
  recovery_lock_store: _RecoveryLockStore,
27
- config: Domain::Config,
24
+ config: Config,
25
+ clock: _Clock,
26
+ run_recorder: Telemetry::RunRecorder,
27
+ emitter: Telemetry::Emitter
28
28
  ) -> void
29
29
 
30
30
  def with_recovery_lock: [T] (
31
31
  fallback: (^(StandardError?) -> T)?,
32
32
  state_snapshot: StateSnapshot,
33
- code: ^() -> T,
34
- ) { () -> T } -> T
33
+ ) { (duration_ms) -> T } -> T
34
+
35
+ def capture_started_at: () -> Float
36
+ def duration_since: (duration_ms) -> duration_ms
37
+
38
+ def record_recovery_probe_success: (
39
+ duration_ms: duration_ms,
40
+ ?error: StandardError?
41
+ ) -> void
42
+
43
+ def record_recovery_probe_failure: (
44
+ StandardError,
45
+ duration_ms: duration_ms,
46
+ fallback_used: bool,
47
+ ) -> void
35
48
 
36
- def record_recovery_probe_success: () -> void
37
- def record_recovery_probe_failure: (StandardError) -> void
38
49
  def enter_recovery: (StateSnapshot) -> void
39
50
  end
40
51
  end
@@ -0,0 +1,49 @@
1
+ module Stoplight
2
+ module Domain
3
+ module Telemetry
4
+ # In-process telemetry bus.
5
+ #
6
+ # Contract:
7
+ # - Events are process-local observations: they describe what this process observed or did, not the
8
+ # globally shared circuit state.
9
+ # - Every color change this process observes or effects emits exactly one +state_transitioned+ event. That
10
+ # stream alone reconstructs the color timeline (breaches, recovery, and locks included).
11
+ # - Events are traffic-driven - no traffic, no events.
12
+ # - Handlers run synchronously on the calling thread and are error-isolated:
13
+ # a raising handler is routed to the error notifier and never affects the run.
14
+ # - Emission allocates nothing when nothing is subscribed to that event class - a transitions-only
15
+ # subscriber keeps RunCompleted emission free.
16
+ # - Publish pays for interested handlers only: no filter matching happens at publish time
17
+ # (interest is resolved at subscribe time), and subscriptions to other event classes add
18
+ # nothing. The handlers themselves run inline, so their cost belongs to the subscriber.
19
+ # Subscribing mid-publish takes effect on the next publish.
20
+ class Bus
21
+ # The consumer side (subscribe/unsubscribe), what +_System#telemetry+ returns.
22
+ include _Telemetry
23
+
24
+ # The producer side (publish/subscribed?), what wiring injects into Emitter.
25
+ include _TelemetryPublisher
26
+
27
+ @error_notifier: error_notifier
28
+ @mutex: Mutex
29
+ @max_subscriptions: Integer
30
+ @subscriptions: Array[[Subscription, subscription_filter, subscription_handler]]
31
+ @dispatch: Hash[Class, Array[subscription_handler]]
32
+
33
+ # Default cap on live subscriptions.
34
+ MAX_SUBSCRIPTIONS: Integer
35
+
36
+ # @param error_notifier receives any StandardError a subscriber's handler raises.
37
+ # @param max_subscriptions caps the number of live subscriptions - #subscribe raises
38
+ # Stoplight::Error::TooManySubscriptions once reached.
39
+ def initialize: (error_notifier: error_notifier, ?max_subscriptions: Integer) -> void
40
+
41
+ # Value-level mirror of the +event+ union. A new event type is added here and to the union
42
+ # together (a spec pins them in sync).
43
+ EVENT_CLASSES: Array[event_class]
44
+
45
+ private def rebuild: -> void
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,13 @@
1
+ module Stoplight
2
+ module Domain
3
+ module Telemetry
4
+ class Consumer
5
+ include _Telemetry
6
+
7
+ @telemetry: untyped
8
+
9
+ def initialize: (_Telemetry) -> void
10
+ end
11
+ end
12
+ end
13
+ end