-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(deadline) removed wasted DeadlineSetupClientInterceptor calls in…
… runtime
- Loading branch information
Бацура Сергей Александрович
authored and
Бацура Сергей Александрович
committed
Sep 4, 2024
1 parent
e14b9fe
commit 7505c7d
Showing
3 changed files
with
10 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* Deadline setup client interceptor that create new deadline instance from deadlineDuration. | ||
* Deadline setup client interceptor that create new deadline instance from defaultDeadline. | ||
* | ||
* @author Sergei Batsura ([email protected]) | ||
*/ | ||
|
@@ -37,17 +37,17 @@ | |
@RequiredArgsConstructor | ||
public class DeadlineSetupClientInterceptor implements ClientInterceptor { | ||
|
||
private final CallOptions.Key<Duration> deadlineDuration; | ||
private final Duration defaultDeadline; | ||
|
||
@Override | ||
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( | ||
final MethodDescriptor<ReqT, RespT> method, | ||
final CallOptions callOptions, | ||
final Channel next) { | ||
|
||
Duration duration = callOptions.getOption(deadlineDuration); | ||
if (duration != null) { | ||
return next.newCall(method, callOptions.withDeadlineAfter(duration.toMillis(), TimeUnit.MILLISECONDS)); | ||
if (defaultDeadline != null) { | ||
return next.newCall(method, | ||
callOptions.withDeadlineAfter(defaultDeadline.toMillis(), TimeUnit.MILLISECONDS)); | ||
} else { | ||
return next.newCall(method, callOptions); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters