16
16
17
17
package com .palantir .dialogue .core ;
18
18
19
+ import com .google .common .annotations .VisibleForTesting ;
19
20
import com .google .common .util .concurrent .ListenableFuture ;
20
21
import com .palantir .dialogue .Endpoint ;
21
22
import com .palantir .dialogue .Request ;
@@ -31,13 +32,17 @@ final class StickyConcurrencyLimitedChannel implements LimitedChannel {
31
32
32
33
private static final Logger log = LoggerFactory .getLogger (StickyConcurrencyLimitedChannel .class );
33
34
34
- private final LimitedChannel delegate ;
35
+ private final NeverThrowLimitedChannel delegate ;
35
36
private final CautiousIncreaseAggressiveDecreaseConcurrencyLimiter limiter ;
36
37
private final String channelNameForLogging ;
37
38
38
- StickyConcurrencyLimitedChannel (LimitedChannel delegate , String channelNameForLogging ) {
39
- this .delegate = delegate ;
40
- this .limiter = new CautiousIncreaseAggressiveDecreaseConcurrencyLimiter (Behavior .STICKY );
39
+ @ VisibleForTesting
40
+ StickyConcurrencyLimitedChannel (
41
+ LimitedChannel delegate ,
42
+ CautiousIncreaseAggressiveDecreaseConcurrencyLimiter limiter ,
43
+ String channelNameForLogging ) {
44
+ this .delegate = new NeverThrowLimitedChannel (delegate );
45
+ this .limiter = limiter ;
41
46
this .channelNameForLogging = channelNameForLogging ;
42
47
}
43
48
@@ -58,7 +63,7 @@ public Optional<ListenableFuture<Response>> maybeExecute(
58
63
Optional <ListenableFuture <Response >> result = delegate .maybeExecute (
59
64
endpoint ,
60
65
request ,
61
- permit .isOnlyInFlight ()
66
+ permit .isOnlyInFlight () || limitEnforcement == LimitEnforcement . DANGEROUS_BYPASS_LIMITS
62
67
? LimitEnforcement .DANGEROUS_BYPASS_LIMITS
63
68
: LimitEnforcement .DEFAULT_ENABLED );
64
69
if (result .isPresent ()) {
@@ -75,7 +80,8 @@ public Optional<ListenableFuture<Response>> maybeExecute(
75
80
}
76
81
77
82
static LimitedChannel create (LimitedChannel channel , String channelName ) {
78
- return new StickyConcurrencyLimitedChannel (channel , channelName );
83
+ return new StickyConcurrencyLimitedChannel (
84
+ channel , new CautiousIncreaseAggressiveDecreaseConcurrencyLimiter (Behavior .STICKY ), channelName );
79
85
}
80
86
81
87
private void logPermitAcquired () {
0 commit comments