Stoplight::Domain::TrafficRecovery defines GREEN, YELLOW, RED to represent a recovery strategy's decision about what to do next:
GREEN — recovered successfully
YELLOW — keep probing, not enough information to decide yet
RED — recovery failed
These share names with Stoplight::Color::GREEN/YELLOW/RED, which represent the light's actual state. The two are conceptually different things that happen to use the same words, which makes it is easy to misread and easy to accidentally couple.
Proposal
Rename the TrafficRecovery constants to something that doesn't overlap with Color at all, e.g.:
GREEN -> RECOVERED
YELLOW -> RECOVERING (or PROBING)
RED -> FAILED_TO_RECOVER
Where this touches
lib/stoplight/domain/traffic_recovery.rb (the constants themselves)
lib/stoplight/domain/traffic_recovery/consecutive_successes.rb (determine_color return values)
lib/stoplight/domain/tracker/recovery_probe.rb (the consumer)
- Any specs asserting against these constants
Stoplight::Domain::TrafficRecoverydefinesGREEN,YELLOW,REDto represent a recovery strategy's decision about what to do next:GREEN— recovered successfullyYELLOW— keep probing, not enough information to decide yetRED— recovery failedThese share names with
Stoplight::Color::GREEN/YELLOW/RED, which represent the light's actual state. The two are conceptually different things that happen to use the same words, which makes it is easy to misread and easy to accidentally couple.Proposal
Rename the
TrafficRecoveryconstants to something that doesn't overlap withColorat all, e.g.:GREEN->RECOVEREDYELLOW->RECOVERING(orPROBING)RED->FAILED_TO_RECOVERWhere this touches
lib/stoplight/domain/traffic_recovery.rb(the constants themselves)lib/stoplight/domain/traffic_recovery/consecutive_successes.rb(determine_colorreturn values)lib/stoplight/domain/tracker/recovery_probe.rb(the consumer)