Skip to content

Conversation

sjy982
Copy link
Contributor

@sjy982 sjy982 commented May 18, 2025

Motivation

  • Pluggable timeout strategies
    StreamMessage.timeout() currently uses a fixed timeout mode. Different
    use-cases may require custom logic, so we introduce a StreamTimeoutStrategy
    interface. The existing StreamTimeoutMode will 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

  1. Add StreamTimeoutDecision
    • Immutable value object containing: timedOut, hasNextSchedule,
      nextScheduleTimeNanos.
    • Provides the factory methods:
      TIMED_OUT, NO_SCHEDULE, scheduleAt(long).
  2. Add StreamTimeoutStrategy interface
    • initialDecision(long subscribeTimeNanos) – called once right after
      subscription.
    • evaluateTimeout(long currentTimeNanos, long lastEventTimeNanos) – called
      each time the scheduled timer fires.
  3. (TODO) Default (StreamTimeoutMode) and token-bucket strategy implementations
    Will be added in a follow-up commit.

Result

sjy982 added 2 commits May 21, 2025 00:48
Update TimeoutStreamMessage, TimeoutSubscriber, StreamMessage
@github-actions github-actions bot added the Stale label Jun 25, 2025
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support custom timeout strategies in StreamMessage.timeout(), with built-in support for a token-bucket timeout-limiting strategy
1 participant