Commit d36a3bd
authored
[registry] Fix token refresh firing every 20s instead of near expiry (#21)
The refresh_interval variable was set to expires_in - 20 after each
refresh, then used in the check `now + refresh_interval >= expired_at`.
Since expired_at = fetch_time + expires_in, this resolved to "refresh
when 20s have passed since last fetch" rather than "refresh 20s before
expiry".
Replace the mutable refresh_interval with a fixed margin constant
so the check correctly triggers only when the token is about to
expire within the next 20 seconds.1 parent f243560 commit d36a3bd
1 file changed
Lines changed: 6 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
1012 | 1014 | | |
1013 | 1015 | | |
1014 | 1016 | | |
1015 | | - | |
1016 | | - | |
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
1023 | 1023 | | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
1027 | 1028 | | |
1028 | 1029 | | |
1029 | 1030 | | |
| |||
1034 | 1035 | | |
1035 | 1036 | | |
1036 | 1037 | | |
1037 | | - | |
1038 | 1038 | | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | 1041 | | |
1048 | 1042 | | |
1049 | 1043 | | |
| |||
0 commit comments