refactor: add separation of concerns in fetcher and platform

This commit is contained in:
Alexander Navarro 2024-11-30 18:14:04 -03:00
parent 96af51ee68
commit 4094f71a7d
5 changed files with 227 additions and 145 deletions

View file

@ -85,7 +85,6 @@ func getPokedexs(
// fmt.Println(data)
payload.Offset += pagination.Limit
payload.HasMore = data.Next != ""
payload.Total = data.Count
payload.Response = collections
@ -166,9 +165,19 @@ func main() {
return
}
pagination := synchronizator.StartPagination
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err = pokeApi.FetchCollections(getPokedexs, pagination)
pagination := synchronizator.StartPagination
pool_config := &synchronizator.WorkConfig{
AmountOfWorkers: 5,
MaxRetries: 3,
BaseRetryTime: time.Second * 2,
RateLimit: synchronizator.NewRateLimiter(5, time.Minute),
Timeout: time.Second * 2,
}
err = pokeApi.FetchCollections(ctx, getPokedexs, pagination, pool_config)
if err != nil {
fmt.Println(err)
return