(res *SaslAuthenticateResponse)
| 1825 | } |
| 1826 | |
| 1827 | func (b *Broker) computeSaslSessionLifetime(res *SaslAuthenticateResponse) { |
| 1828 | if res.SessionLifetimeMs > 0 { |
| 1829 | // Follows the Java Kafka implementation from SaslClientAuthenticator.ReauthInfo#setAuthenticationEndAndSessionReauthenticationTimes |
| 1830 | // pick a random percentage between 85% and 95% for session re-authentication |
| 1831 | positiveSessionLifetimeMs := res.SessionLifetimeMs |
| 1832 | authenticationEndMs := currentUnixMilli() |
| 1833 | pctWindowFactorToTakeNetworkLatencyAndClockDriftIntoAccount := 0.85 |
| 1834 | pctWindowJitterToAvoidReauthenticationStormAcrossManyChannelsSimultaneously := 0.10 |
| 1835 | pctToUse := pctWindowFactorToTakeNetworkLatencyAndClockDriftIntoAccount + rand.Float64()*pctWindowJitterToAvoidReauthenticationStormAcrossManyChannelsSimultaneously |
| 1836 | sessionLifetimeMsToUse := int64(float64(positiveSessionLifetimeMs) * pctToUse) |
| 1837 | DebugLogger.Printf("Session expiration in %d ms and session re-authentication on or after %d ms", positiveSessionLifetimeMs, sessionLifetimeMsToUse) |
| 1838 | b.clientSessionReauthenticationTimeMs = authenticationEndMs + sessionLifetimeMsToUse |
| 1839 | } else { |
| 1840 | b.clientSessionReauthenticationTimeMs = 0 |
| 1841 | } |
| 1842 | } |
| 1843 | |
| 1844 | func (b *Broker) updateIncomingCommunicationMetrics(bytes int, requestLatency time.Duration) { |
| 1845 | b.updateRequestLatencyAndInFlightMetrics(requestLatency) |
no test coverage detected