Closed HigorCesar closed 6 years ago
I think passing in a CancellationToken is only needed if you ever want to cancel the operation from the outside, if you don't want to do that, you can omit the argument. @JorritSalverda is there any situation when it's needed?
It's to make sure that if the circuit breaker times out before the code it executes does it cancels that code. You use it as follows:
var cancellationTokenSource = new CancellationTokenSource();
var client = new System.Net.Http.HttpClient();
var response = await hystrixCommandFactory.GetHystrixCommand("group", "command").ExecuteAsync(
async () => await client.GetAsync(url, cancellationTokenSource.Token).ConfigureAwait(false)
, cancellationTokenSource).ConfigureAwait(false);
So if your circuit breaker has a 1 second timeout and the HttpClient 30 seconds without it it would continue to run up to 30 seconds, whereas with the cancellationtoken it get's cancelled after 1 second.
Considering that Hystrix handles time out is necessary to call ExecuteAsync with CancellationTokenSource properly configured?