touchDailyWindow rolls over the daily counter when the previous window has elapsed. Returns whether a rollover occurred so the caller can log it outside the endpointMu critical section. Caller must hold c.endpointMu.
(ep *relayEndpoint, now time.Time)
| 39 | // |
| 40 | // Caller must hold c.endpointMu. |
| 41 | func (c *Client) touchDailyWindow(ep *relayEndpoint, now time.Time) (rolledOver bool) { |
| 42 | if ep.dailyResetAt.IsZero() { |
| 43 | ep.dailyResetAt = nextQuotaReset(now) |
| 44 | return false |
| 45 | } |
| 46 | if now.Before(ep.dailyResetAt) { |
| 47 | return false |
| 48 | } |
| 49 | ep.dailyCount = 0 |
| 50 | ep.dailyResetAt = nextQuotaReset(now) |
| 51 | return true |
| 52 | } |
| 53 | |
| 54 | // bumpDailyCount records one Apps Script invocation for an endpoint. |
| 55 | // |
no test coverage detected