mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 16:17:25 +00:00
fix(channels): pending message compaction never triggering
Move count assignment before RAM trim in Record() so MaybeCompact receives pre-trim count (51) that exceeds threshold (50), allowing compaction to fire. Previously count was always ≤ limit after trim.
This commit is contained in:
1 parent
bdb60de7ae
commit
30080f1acf
1 file changed
+1
-1
@@ -120,11 +120,11 @@ func (ph *PendingHistory) Record(historyKey string, entry HistoryEntry, limit in
|
||||
ph.mu.Lock()
|
||||
existing := ph.entries[historyKey]
|
||||
existing = append(existing, entry)
|
||||
count = len(existing) // capture pre-trim count so MaybeCompact sees threshold exceeded
|
||||
if len(existing) > limit {
|
||||
existing = existing[len(existing)-limit:]
|
||||
}
|
||||
ph.entries[historyKey] = existing
|
||||
count = len(existing)
|
||||
ph.removeFromOrder(historyKey)
|
||||
ph.order = append(ph.order, historyKey)
|
||||
ph.evictOldKeys()
|
||||
|
||||
Reference in new issue
Block a user