populateDefaults populates the zero value options with defaults
(options CorrelatorOptions)
| 462 | |
| 463 | // populateDefaults populates the zero value options with defaults |
| 464 | func populateDefaults(options CorrelatorOptions) CorrelatorOptions { |
| 465 | if options.LRUCacheSize == 0 { |
| 466 | options.LRUCacheSize = maxLruCacheEntries |
| 467 | } |
| 468 | if options.BurstSize == 0 { |
| 469 | options.BurstSize = defaultSpamBurst |
| 470 | } |
| 471 | if options.QPS == 0 { |
| 472 | options.QPS = defaultSpamQPS |
| 473 | } |
| 474 | if options.KeyFunc == nil { |
| 475 | options.KeyFunc = EventAggregatorByReasonFunc |
| 476 | } |
| 477 | if options.MessageFunc == nil { |
| 478 | options.MessageFunc = EventAggregatorByReasonMessageFunc |
| 479 | } |
| 480 | if options.MaxEvents == 0 { |
| 481 | options.MaxEvents = defaultAggregateMaxEvents |
| 482 | } |
| 483 | if options.MaxIntervalInSeconds == 0 { |
| 484 | options.MaxIntervalInSeconds = defaultAggregateIntervalInSeconds |
| 485 | } |
| 486 | if options.Clock == nil { |
| 487 | options.Clock = clock.RealClock{} |
| 488 | } |
| 489 | return options |
| 490 | } |
| 491 | |
| 492 | // EventCorrelate filters, aggregates, counts, and de-duplicates all incoming events |
| 493 | func (c *EventCorrelator) EventCorrelate(newEvent *v1.Event) (*EventCorrelateResult, error) { |
no outgoing calls
no test coverage detected