fix(correlation): Keep-Alive time window + orphan timer + TTL purge (v1.1.14)
Bug #1 - processSourceA: utilise bEventHasValidTTL en mode one_to_many au lieu de eventsMatch qui comparait les timestamps originaux. Apres ~10s les requetes A devenaient toutes orphelines alors que la session KA etait active. Bug #4 - checkPendingOrphansForCorrelation: meme correction, cle identique = meme connexion en one_to_many, pas besoin de comparer les timestamps. Bug #3 - cleanNetworkBufferByTTL: expiration B => emission immediate des pending orphans associes (ils ne peuvent plus jamais corréler). Bug #2 - Orchestrateur: goroutine ticker 250ms appelle EmitPendingOrphans() pour drainer les orphans independamment du flux d'evenements entrants. EmitPendingOrphans() expose la methode comme publique thread-safe. Tests: 4 nouveaux tests de non-regression (un par bug). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@ -15,6 +15,10 @@ const (
|
||||
DefaultEventChannelBufferSize = 1000
|
||||
// ShutdownTimeout is the maximum time to wait for graceful shutdown
|
||||
ShutdownTimeout = 30 * time.Second
|
||||
// OrphanTickInterval is how often the orchestrator drains pending orphans.
|
||||
// Set to half the default emit delay (500ms/2) so orphans are emitted promptly
|
||||
// even when no new events arrive.
|
||||
OrphanTickInterval = 250 * time.Millisecond
|
||||
)
|
||||
|
||||
// OrchestratorConfig holds the orchestrator configuration.
|
||||
@ -77,6 +81,27 @@ func (o *Orchestrator) Start() error {
|
||||
}(source, eventChan)
|
||||
}
|
||||
|
||||
// Start a periodic ticker to drain pending orphan A events independently of the
|
||||
// event flow. Without this, orphans are only emitted when a new event arrives,
|
||||
// causing them to accumulate silently when the source goes quiet.
|
||||
o.wg.Add(1)
|
||||
go func() {
|
||||
defer o.wg.Done()
|
||||
ticker := time.NewTicker(OrphanTickInterval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-o.ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
logs := o.correlationSvc.EmitPendingOrphans()
|
||||
for _, log := range logs {
|
||||
o.config.Sink.Write(o.ctx, log) //nolint:errcheck
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user