File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -272,13 +272,9 @@ func (e *entraidTokenManager) durationToRenewal(t *token.Token) time.Duration {
272
272
return 0
273
273
}
274
274
275
- // Calculate refresh time using integer math:
276
- // 1. TTL is already in milliseconds
277
- // 2. Multiply by refresh ratio (as integer percentage)
278
- // 3. Add to received time
279
- ttlMillis := t .TTL () // Already in milliseconds
280
- refreshRatioInt := int64 (e .expirationRefreshRatio * 100 ) // Convert to integer percentage
281
- refreshMillis := (ttlMillis * refreshRatioInt ) / 100 // Integer division for ratio
275
+ ttlMillis := t .TTL () // Already in milliseconds
276
+ // let's not lose the precision here, examples use 0.001, which would be lost with integer math
277
+ refreshMillis := int64 (float64 (ttlMillis ) * e .expirationRefreshRatio )
282
278
refreshTimeMillis := t .ReceivedAt ().UnixMilli () + refreshMillis
283
279
284
280
// Calculate time until refresh
You can’t perform that action at this time.
0 commit comments