Add rate limit cache and fixes
This change adds a loop that keeps a cache of credentials rate limits as reported by the github API. The cache is updated every 30 seconds and is purely informational for the user. This change also adds some caching improvements. Functions that return values from the cache as lists, will now sort by ID or creation date. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
16af8fd97f
commit
1a719567ff
10 changed files with 276 additions and 23 deletions
|
|
@ -375,6 +375,8 @@ func formatOneGithubCredential(cred params.GithubCredentials) {
|
|||
header := table.Row{"Field", "Value"}
|
||||
t.AppendHeader(header)
|
||||
|
||||
resetMinutes := cred.RateLimit.ResetIn().Minutes()
|
||||
|
||||
t.AppendRow(table.Row{"ID", cred.ID})
|
||||
t.AppendRow(table.Row{"Created At", cred.CreatedAt})
|
||||
t.AppendRow(table.Row{"Updated At", cred.UpdatedAt})
|
||||
|
|
@ -385,6 +387,10 @@ func formatOneGithubCredential(cred params.GithubCredentials) {
|
|||
t.AppendRow(table.Row{"Upload URL", cred.UploadBaseURL})
|
||||
t.AppendRow(table.Row{"Type", cred.AuthType})
|
||||
t.AppendRow(table.Row{"Endpoint", cred.Endpoint.Name})
|
||||
if resetMinutes > 0 {
|
||||
t.AppendRow(table.Row{"Remaining API requests", cred.RateLimit.Remaining})
|
||||
t.AppendRow(table.Row{"Rate limit reset", fmt.Sprintf("%d minutes", int64(resetMinutes))})
|
||||
}
|
||||
|
||||
if len(cred.Repositories) > 0 {
|
||||
t.AppendRow(table.Row{"", ""})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue