-
Notifications
You must be signed in to change notification settings - Fork 16
/
IHystrixCommand.cs
65 lines (57 loc) · 3.16 KB
/
IHystrixCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Hystrix.Dotnet
{
public interface IHystrixCommand
{
/// <summary>
/// Returns the identifier
/// </summary>
HystrixCommandIdentifier CommandIdentifier { get; }
/// <summary>
/// Returns the internal circuit breaker
/// </summary>
IHystrixCircuitBreaker CircuitBreaker { get; }
/// <summary>
/// Exposes the metrics
/// </summary>
IHystrixCommandMetrics CommandMetrics { get; }
IHystrixThreadPoolMetrics ThreadPoolMetrics { get; }
IHystrixConfigurationService ConfigurationService { get; }
/// <summary>
/// Runs the synchronous <paramref name="primaryFunction"/> wrapped by circuit breaker and timeout pattern, without a fallback; an error, timeout or open circuit breaker will result in a <see cref="HystrixCommandException"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="primaryFunction">The operation to execute.</param>
/// <param name="cancellationTokenSource">The cancellation token source.</param>
/// <returns></returns>
T Execute<T>(Func<T> primaryFunction, CancellationTokenSource cancellationTokenSource = null);
/// <summary>
/// Runs the synchronous <paramref name="primaryFunction"/> wrapped by circuit breaker and timeout pattern, with a fallback function; an error, timeout or open circuit breaker will execute the <paramref name="fallbackFunction"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="primaryFunction"></param>
/// <param name="fallbackFunction"></param>
/// <param name="cancellationTokenSource"></param>
/// <returns></returns>
T Execute<T>(Func<T> primaryFunction, Func<T> fallbackFunction, CancellationTokenSource cancellationTokenSource = null);
/// <summary>
/// Runs the asynchronous <paramref name="primaryFunction"/> wrapped by circuit breaker and timeout pattern, without a fallback; an error, timeout or open circuit breaker will result in a <see cref="HystrixCommandException"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="primaryFunction"></param>
/// <param name="cancellationTokenSource"></param>
/// <returns></returns>
Task<T> ExecuteAsync<T>(Func<Task<T>> primaryFunction, CancellationTokenSource cancellationTokenSource = null);
/// <summary>
/// Runs the asynchronous <paramref name="primaryFunction"/> wrapped by circuit breaker and timeout pattern, with a fallback function; an error, timeout or open circuit breaker will execute the <paramref name="fallbackFunction"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="primaryFunction"></param>
/// <param name="fallbackFunction"></param>
/// <param name="cancellationTokenSource"></param>
/// <returns></returns>
Task<T> ExecuteAsync<T>(Func<Task<T>> primaryFunction, Func<Task<T>> fallbackFunction, CancellationTokenSource cancellationTokenSource = null);
}
}