4. Combining Policies to Protect Against Many Types of Failure Flashcards
What does wrapping allow us to do in regards to resilience?
They allow us to combine multiple layers of resilience when calling a remote service.
What does wrapping mean for us when it comes to code readability?
Wrapping can help us make our code shorter and easier to read.
What does wrapping offer us in terms of code reuse?
It encourages the reuse of combinations of policies.
Which one does wrapping work with — generic or non-generic policies?
Both.
What can be said about wrapping policies when it comes to policy interfaces?
Wrapping can be used with policy interfaces instead of concrete types.
What’s can be said about the syntactical difference between wrapping generic policies vs wrapping them together with non-generic policies?
Wrapping generic policies is less complex, whereas wrapping them together with non-generic policies is slightly more complex.
What interface can you use for policy wraps to be able to unit test them?
The IPolicyWrap
interface.
How do we wrap generic policies?
By using the Wrap
or WrapAsync
method (depending on the synchronicity of policies) of the Policy
method.
Policy.WrapAsync( _fallbackPolicy, _retryPolicy, _timeoutPolicy);
How do we wrap generic and non-generic policies together?
By using the .Wrap
or .WrapAsync
method of Policy
objects.
_fallbackPolicy .WrapAsync(_retryPolicy .WrapAsync(_timeoutPolicy));