|
1 | | -namespace NServiceBus.Transport.Sql.Shared; |
| 1 | +#nullable enable |
| 2 | + |
| 3 | +namespace NServiceBus.Transport.Sql.Shared; |
2 | 4 |
|
3 | 5 | using System; |
4 | 6 | using System.Threading; |
@@ -42,18 +44,18 @@ public RepeatedFailuresOverTimeCircuitBreaker( |
42 | 44 | string name, |
43 | 45 | TimeSpan timeToWaitBeforeTriggering, |
44 | 46 | Action<Exception> triggerAction, |
45 | | - Action armedAction = null, |
46 | | - Action disarmedAction = null, |
47 | | - TimeSpan timeToWaitWhenTriggered = default, |
48 | | - TimeSpan timeToWaitWhenArmed = default) |
| 47 | + Action? armedAction = null, |
| 48 | + Action? disarmedAction = null, |
| 49 | + TimeSpan? timeToWaitWhenTriggered = default, |
| 50 | + TimeSpan? timeToWaitWhenArmed = default) |
49 | 51 | { |
50 | 52 | this.name = name; |
51 | 53 | this.triggerAction = triggerAction; |
52 | 54 | this.armedAction = armedAction ?? (static () => { }); |
53 | 55 | this.disarmedAction = disarmedAction ?? (static () => { }); |
54 | 56 | this.timeToWaitBeforeTriggering = timeToWaitBeforeTriggering; |
55 | | - this.timeToWaitWhenTriggered = timeToWaitWhenTriggered == TimeSpan.MinValue ? TimeSpan.FromSeconds(10) : timeToWaitWhenTriggered; |
56 | | - this.timeToWaitWhenArmed = timeToWaitWhenArmed == TimeSpan.MinValue ? TimeSpan.FromSeconds(1) : timeToWaitWhenArmed; |
| 57 | + this.timeToWaitWhenTriggered = timeToWaitWhenTriggered ?? TimeSpan.FromSeconds(10); |
| 58 | + this.timeToWaitWhenArmed = timeToWaitWhenArmed ?? TimeSpan.FromSeconds(1); |
57 | 59 |
|
58 | 60 | timer = new Timer(CircuitBreakerTriggered); |
59 | 61 | } |
@@ -154,7 +156,7 @@ Task Delay() |
154 | 156 | /// </summary> |
155 | 157 | public void Dispose() => timer.Dispose(); |
156 | 158 |
|
157 | | - void CircuitBreakerTriggered(object state) |
| 159 | + void CircuitBreakerTriggered(object? state) |
158 | 160 | { |
159 | 161 | var previousState = Volatile.Read(ref circuitBreakerState); |
160 | 162 | if (previousState == Disarmed) |
@@ -187,7 +189,7 @@ void CircuitBreakerTriggered(object state) |
187 | 189 | public bool IsTriggered => circuitBreakerState == Triggered; |
188 | 190 |
|
189 | 191 | int circuitBreakerState = Disarmed; |
190 | | - Exception lastException; |
| 192 | + Exception? lastException; |
191 | 193 |
|
192 | 194 | readonly string name; |
193 | 195 | readonly Timer timer; |
|
0 commit comments