fix: replace RunContext
and ProjectContext
contextValues
with concurrency safe ContextValues
#2544
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.
This change introduces the ContextValues struct to both RunContext and ProjectContext, replacing the previously used
map[string]interface{}
. This change was introduced to enhance thread safety in our codebase by preventing concurrent read/write operations to these shared resources, which could lead to unpredictable behavior or data races.Prior to this change the
ContextValues()
could hit a conccurent write panic because it was returning the actual map and not a copy of it, so when we read from the map it could potentially be written to in a separate goroutine.To fix this
Values
now returns a copy of the underlying map. I've also introduced aGetValue
method to safely read values.