gc prunes the sequence partial if it remained more time than specified by max span or if max span is omitted, the partial is allowed to remain in sequence state for four hours.
()
| 347 | // span is omitted, the partial is allowed to remain |
| 348 | // in sequence state for four hours. |
| 349 | func (s *sequenceState) gc() { |
| 350 | s.mu.Lock() |
| 351 | defer s.mu.Unlock() |
| 352 | dur := s.maxSpan |
| 353 | if dur == 0 { |
| 354 | dur = maxSequencePartialLifetime |
| 355 | } |
| 356 | for idx := range s.exprs { |
| 357 | for i := len(s.partials[idx]) - 1; i >= 0; i-- { |
| 358 | if len(s.partials[idx]) > 0 && time.Since(s.partials[idx][i].Timestamp) > dur { |
| 359 | log.Debugf("garbage collecting partial: [%s] of sequence [%s]", s.partials[idx][i], s.name) |
| 360 | // remove partial event from the corresponding slot |
| 361 | s.partials[idx] = append( |
| 362 | s.partials[idx][:i], |
| 363 | s.partials[idx][i+1:]...) |
| 364 | partialsPerSequence.Add(s.name, -1) |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | func (s *sequenceState) clear() { |
| 371 | s.partials = make(map[int][]*event.Event) |