Outcome chaos strategy #1978
Replies: 3 comments 8 replies
-
Yeah, at this point we need to leave it as it is. Not a big deal though.
let's make
I agree, it's clumsy :/. The hedging generator is slightly different, it's not the task that is nullable, but the action generator: Func<ValueTask<Outcome>>? An even worse, I think we have a bug here, if I would say let's close our eyes for a second make sure no-one is watching and do a breaking change. It's only nullable annotation though:
@martincostello Thoughts?
This is true when someone uses chaos outcome strategy ONLY to inject exceptions. In that case the fault chaos should be used. However, using chaos outcome to inject both results and exceptions is IMHO a valid pattern. |
Beta Was this translation helpful? Give feedback.
-
I agree with @martintmk that using the outcome chaos strategy to inject exceptions does not feel wrong, however, I also think that we should be clear in the docs and explain the "caveats/implications" of doing so, for example, metrics are one of them, for instrumentation purposes it's way clearer looking for fault injected events to be 100% sure where/when exceptions were injected, not to mention that when using the OnOutcomeInjected delegate the consumer might need to check if the outcome was an exception, etc. @peter-csala So in that sense, IMHO it could become an anti-pattern, so yeah definitively it is worth explaining that in the docs. |
Beta Was this translation helpful? Give feedback.
-
Just to summarize:
|
Beta Was this translation helpful? Give feedback.
-
I was preparing some sample code for the outcome chaos strategy cheat sheet.
I'm bumped into the following inconsistencies:
Note
Am I right that we can't really do anything without introducing a breaking change?
FaultGenerator
vsOutcomeGenerator
It is required but can be
null
It is required and can't be
null
Note
Can we fix
FaultGenerator
by not allowingnull
?Outcome.FromResultAsValueTask
Due to the fact that the return type is defined as
ValueTask<Outcome<TResult>?>
creating a synchronous result is really clumsy
if it could be
ValueTask<Outcome<TResult>>?
similar to Hedging'sActionGenerator
Polly/src/Polly.Core/Hedging/HedgingStrategyOptions.TResult.cs
Line 55 in 3e2164e
then people could use
Outcome.FromResultAsValueTask
:Note
Can we fix the return type of
OutcomeGenerator
?I think it might make sense to emphasize in the documentation that
Outcome
chaos strategy should NOT be used to inject exception. IMHO adding an anti-pattern by using theOutcome.FromException
could be helpful.Also I think it would make sense to add some sample code where we use both
Fault
andOutcome
strategies to show how to use them as intended.Note
Do you guys agree?
cc: @martincostello , @martintmk , @vany0114
Beta Was this translation helpful? Give feedback.
All reactions