(throttleTime time.Duration)
| 1935 | } |
| 1936 | |
| 1937 | func (b *Broker) setThrottle(throttleTime time.Duration) { |
| 1938 | b.throttleTimerLock.Lock() |
| 1939 | defer b.throttleTimerLock.Unlock() |
| 1940 | if b.throttleTimer != nil { |
| 1941 | // if there is an existing timer stop/clear it |
| 1942 | if !b.throttleTimer.Stop() { |
| 1943 | <-b.throttleTimer.C |
| 1944 | } |
| 1945 | } |
| 1946 | b.throttleTimer = time.NewTimer(throttleTime) |
| 1947 | } |
| 1948 | |
| 1949 | func (b *Broker) waitIfThrottled() { |
| 1950 | b.throttleTimerLock.Lock() |
no test coverage detected