armeria
armeria copied to clipboard
Add StreamTimeoutStrategy, StreamTimeoutDecision, and Token-bucket-based timeout limiting strategy
Motivation
- Pluggable timeout strategies
StreamMessage.timeout()currently uses a fixed timeout mode. Different use-cases may require custom logic, so we introduce aStreamTimeoutStrategyinterface. The existingStreamTimeoutModewill remain as the default strategy. - Token-bucket-based timeout limiting
To tolerate transient network jitter, a token-bucket strategy can delay timeout until a user-defined number of consecutive delays is reached.
Modifications
- Add
StreamTimeoutDecision- Immutable value object containing:
timedOut,hasNextSchedule,nextScheduleTimeNanos. - Provides the factory methods:
TIMED_OUT,NO_SCHEDULE,scheduleAt(long).
- Immutable value object containing:
- Add
StreamTimeoutStrategyinterfaceinitialDecision(long subscribeTimeNanos)– called once right after subscription.evaluateTimeout(long currentTimeNanos, long lastEventTimeNanos)– called each time the scheduled timer fires.
- (TODO) Default (
StreamTimeoutMode) and token-bucket strategy implementations
Will be added in a follow-up commit.
Result
- Users can pass a custom
StreamTimeoutStrategytoStreamMessage.timeout(strategy)to control per-stream timeout behaviour. - The existing enum
StreamTimeoutModecontinues to work as the default. - Closes #6237.
🔍 Build Scan® (commit: f80c2515e25db3f84cff92a48a3efcd3fd731714)
| Job name | Status | Build Scan® |
|---|---|---|
| build-ubicloud-standard-16-jdk-8 | ✅ | https://ge.armeria.dev/s/vbsdqucj4w3vu |
| build-ubicloud-standard-16-jdk-21-snapshot-blockhound | ✅ | https://ge.armeria.dev/s/n5uy45bkomyko |
| build-ubicloud-standard-16-jdk-17-min-java-17-coverage | ✅ | https://ge.armeria.dev/s/7vpqv2cnur2sc |
| build-ubicloud-standard-16-jdk-17-min-java-11 | ✅ | https://ge.armeria.dev/s/qvuvaqyhxjef4 |
| build-ubicloud-standard-16-jdk-17-leak | ✅ | https://ge.armeria.dev/s/3fbxcvbh4dly2 |
| build-ubicloud-standard-16-jdk-11 | ✅ | https://ge.armeria.dev/s/stqfwqlen5k2c |
| build-macos-latest-jdk-21 | ✅ | https://ge.armeria.dev/s/2quqym4g77slc |
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 0.00%. Comparing base (
8150425) to head (f80c251). Report is 106 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #6245 +/- ##
============================================
- Coverage 74.46% 0 -74.47%
============================================
Files 1963 0 -1963
Lines 82437 0 -82437
Branches 10764 0 -10764
============================================
- Hits 61385 0 -61385
+ Misses 15918 0 -15918
+ Partials 5134 0 -5134
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.