fix(titus): Fix SagaContext wiring in DeployHandler cases #4070
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.
It turns out that TitusDeployHandler (and other DeployHandler classes) are singleton components
that get injected into prototype AtomicOperation components, which I didn't realize until now.
The issue with this is that I was setting request-scoped context into a singleton bean, which
could lead to some neat concurrency bugs. This change modifies things for DeployAtomicOperation
specifically to inject the SagaContext into the description (which is actually request-scoped)
rather than passing through to the TitusDeployHandler object.
There's also this neat feature I discovered while working through this where we convert the raw request input into an atomic operation description twice, throwing away the first conversion after we've validated the input. Not sure why we do this, but it seems like something we could make better someday.