mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	Sleep longer if request speed is over github limitation (#9335)
* Sleep longer if request speed is over github limitation * improve code * remove unused code * fix lint * Use github's rate limit remain value to determine how long to sleep * Save reset time when finished github api request * fix bug * fix lint * Add context.Context for sleep * fix test * improve code * fix bug and lint * fix import order
This commit is contained in:
		
				
					committed by
					
						 techknowlogick
						techknowlogick
					
				
			
			
				
	
			
			
			
						parent
						
							d1a49977b0
						
					
				
				
					commit
					ffc904b1e0
				
			| @@ -6,6 +6,7 @@ | ||||
| package base | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"time" | ||||
|  | ||||
| 	"code.gitea.io/gitea/modules/structs" | ||||
| @@ -13,6 +14,7 @@ import ( | ||||
|  | ||||
| // Downloader downloads the site repo informations | ||||
| type Downloader interface { | ||||
| 	SetContext(context.Context) | ||||
| 	GetRepoInfo() (*Repository, error) | ||||
| 	GetTopics() ([]string, error) | ||||
| 	GetMilestones() ([]*Milestone, error) | ||||
| @@ -30,6 +32,10 @@ type DownloaderFactory interface { | ||||
| 	GitServiceType() structs.GitServiceType | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	_ Downloader = &RetryDownloader{} | ||||
| ) | ||||
|  | ||||
| // RetryDownloader retry the downloads | ||||
| type RetryDownloader struct { | ||||
| 	Downloader | ||||
| @@ -46,6 +52,11 @@ func NewRetryDownloader(downloader Downloader, retryTimes, retryDelay int) *Retr | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // SetContext set context | ||||
| func (d *RetryDownloader) SetContext(ctx context.Context) { | ||||
| 	d.Downloader.SetContext(ctx) | ||||
| } | ||||
|  | ||||
| // GetRepoInfo returns a repository information with retry | ||||
| func (d *RetryDownloader) GetRepoInfo() (*Repository, error) { | ||||
| 	var ( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user