Separate light and system settings#696
Open
bolshakov wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stoplight has two fundamentally different kinds of configuration that were previously mixed into the same parameter list:
Infrastructure configuration - how circuit breaker state is stored and reported:
data_store- where failure counts and state live (Memory, Redis)notifiers— who gets told when a light changes colorerror_notifier— who gets told when Stoplight itself has an internal errorBehavior configuration — when a circuit breaks and recovers:
threshold,cool_off_time,window_size,recovery_thresholdtracked_errors,skipped_errorstraffic_control,traffic_recoveryThese have different concerns. Infrastructure is a singleton operational decision - the whole application shares one Redis connection, one set of Slack notifiers. Behavior is per-circuit — the payment gateway trips at 5 errors in 60 seconds, the recommendation engine can tolerate more. Previously, Stoplight let you mix them freely, which caused a real class of bugs.
The footgun this eliminates:
Every call to
Stoplight()here creates a freshMemorystore. SinceMemorystores state in a plain hash, each invocation starts with zero failures recorded. The circuit breaker never trips — it silently discards all failure history on every call. The behavior just doesn’t work.This PR makes it a hard error.
data_store:,notifiers:, anderror_notifier:are no longer valid parameters toStoplight(). You configure infrastructure once at boot:The right configuration lives in the right place, and the wrong thing is impossible to express.
Migration
The change is mechanical for the vast majority of users:
Escape Hatch: Systems
If you have genuinely separate infrastructure boundaries - say, one Redis for payment circuits and another for background jobs —
Stoplight.systemlets you own that explicitly:Most applications will never need this.