Skip to content

Commit 70db08e

Browse files
committed
fix(manager): precision as variable, fix typo
1 parent 7998ce1 commit 70db08e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

manager/entraid_manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,10 @@ func (e *entraidTokenManager) durationToRenewal(t *token.Token) time.Duration {
272272
// e.expirationRefreshRatio = 0.001
273273
// - with int math and 100 precision: 10000 * (0.001*100) = 0ms
274274
// - with int math and 10000 precision: 10000 * (0.001*10000) = 100ms
275+
precision := int64(10000)
275276
ttlMillis := t.TTL() // Already in milliseconds
276-
refreshRationInt := int64(e.expirationRefreshRatio * 10000)
277-
refreshMillis := ttlMillis * refreshRationInt / 10000
277+
refreshRatioInt := int64(e.expirationRefreshRatio * float64(precision))
278+
refreshMillis := ttlMillis * refreshRatioInt / precision
278279
refreshTimeMillis := t.ReceivedAt().UnixMilli() + refreshMillis
279280

280281
// Calculate time until refresh

0 commit comments

Comments
 (0)