Skip to content

Commit 1c5016a

Browse files
committed
chore(manager): improve comments
1 parent 4e61f88 commit 1c5016a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

manager/entraid_manager.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,14 @@ func (e *entraidTokenManager) stop() (err error) {
223223
err = fmt.Errorf("failed to stop token manager: %s", r)
224224
}
225225
}()
226+
if e.ctxCancel != nil {
227+
e.ctxCancel()
228+
}
226229

227230
if e.closedChan == nil || e.listener == nil {
228231
return ErrTokenManagerAlreadyStopped
229232
}
230233

231-
e.ctxCancel()
232234
e.listener = nil
233235
close(e.closedChan)
234236

token/token.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ var _ auth.Credentials = (*Token)(nil)
1111

1212
// New creates a new token with the specified username, password, raw token, expiration time, received at time, and time to live.
1313
// NOTE: This won't do any validation on the token, expiresOn, receivedAt, or ttl. It will simply create a new token instance.
14-
// ttl is in milliseconds.
14+
// The caller is responsible for ensuring the token is valid.
15+
// Expiration time and TTL are used to determine when the token should be refreshed.
16+
// TTL is in milliseconds.
17+
// receivedAt + ttl should be within a millisecond of expiresOn
1518
func New(username, password, rawToken string, expiresOn, receivedAt time.Time, ttl int64) *Token {
1619
return &Token{
1720
username: username,
@@ -32,11 +35,11 @@ type Token struct {
3235
password string
3336
// expiresOn is the expiration time of the token.
3437
expiresOn time.Time
35-
// ttl is the time to live of the token.
38+
// ttl is the time to live of the token in milliseconds.
3639
ttl int64
3740
// rawToken is the authentication token.
3841
rawToken string
39-
// receivedAt is the time when the token was received.
42+
// receivedAt is the time when the token was received
4043
receivedAt time.Time
4144
}
4245

0 commit comments

Comments
 (0)