(tenantHost, destinationID string)
| 411 | } |
| 412 | |
| 413 | func (e *Emitter) allowRate(tenantHost, destinationID string) bool { |
| 414 | ctx := context.Background() |
| 415 | min := time.Now().Unix() / 60 |
| 416 | key := tenantRedisKey(tenantHost, fmt.Sprintf("notif:rl:%s:%d", destinationID, min)) |
| 417 | n, err := e.rdb.Incr(ctx, key).Result() |
| 418 | if err != nil { |
| 419 | return true |
| 420 | } |
| 421 | if n == 1 { |
| 422 | _ = e.rdb.Expire(ctx, key, 2*time.Minute).Err() |
| 423 | } |
| 424 | return n <= ratePerMinute |
| 425 | } |
| 426 | |
| 427 | // cancelPairs maps an event type to the delayed event type it should cancel. |
| 428 | // When host_recovered fires, any pending delayed host_down notification for the same reference should be suppressed. |
no test coverage detected