MCPcopy
hub / github.com/IBM/sarama / computeSaslSessionLifetime

Method computeSaslSessionLifetime

broker.go:1827–1842  ·  view source on GitHub ↗
(res *SaslAuthenticateResponse)

Source from the content-addressed store, hash-verified

1825}
1826
1827func (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
1844func (b *Broker) updateIncomingCommunicationMetrics(bytes int, requestLatency time.Duration) {
1845 b.updateRequestLatencyAndInFlightMetrics(requestLatency)

Callers 1

authenticateViaSASLv1Method · 0.95

Calls 2

currentUnixMilliFunction · 0.85
PrintfMethod · 0.65

Tested by

no test coverage detected