[ISSUE #10387] Support runtime hot-reload of maxClientEventCount in LiteEventDispatcher.ClientEventSet#10388
Open
f1amingo wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #10388 +/- ##
=============================================
- Coverage 48.89% 48.88% -0.01%
+ Complexity 13452 13448 -4
=============================================
Files 1376 1376
Lines 100527 100540 +13
Branches 12983 12984 +1
=============================================
- Hits 49154 49153 -1
+ Misses 45383 45360 -23
- Partials 5990 6027 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…t in LiteEventDispatcher.ClientEventSet
b57b10e to
d7eda2f
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which Issue(s) This PR Fixes
Brief Description
ClientEventSetinLiteEventDispatcherpreviously used a fixed-capacityLinkedBlockingQueuewhose capacity was bound at construction time, which meant the broker had to be restarted whenevermaxClientEventCountwas changed.isLowWaterMark()also relied onremainingCapacity()— for a fixed queue, this is a static number rather than the intended dynamic limit.This PR introduces a TTL-based capacity cache combined with a dynamic soft-cap pattern:
Hard-ceiling unbounded queue: Replace the fixed-capacity constructor with
new LinkedBlockingQueue<>(100_000)as a safety hard ceiling.TTL-based capacity cache: Add a
maxCapacityCachefield that is lazily refreshed everyliteEventCapacityCacheTtlMs(default 5s, configurable inBrokerConfig), avoiding per-offerSubscriptionGroupConfiglookup/parsing on the hot dispatch path while still supporting runtime hot-reload.Dynamic soft-cap in offer(): Check
events.size() >= getMaxCapacity()instead ofremainingCapacity() == 0, so the effective limit tracks the cached config value.Correct watermark calculation: Compute
isLowWaterMark()from dynamicmaxCapacitydirectly, with amaxCapacity <= 0boundary guard.New config: Add
BrokerConfig.liteEventCapacityCacheTtlMs(default 5000ms) to control the refresh interval of the capacity cache.Test fix: Use
doReturn(...).when(spy)...instead ofwhen(spy.method()).thenReturn(...)to avoid invoking real methods on the spy object.How Did You Test This Change?
LiteEventDispatcherTestspy stub style todoReturnto prevent real method invocation on inner-class spy objects.LiteEventDispatcherTestcases coveringoffer,isLowWaterMark, and the full dispatch flow continue to pass locally.