Removed retries
This commit is contained in:
parent
732faa341a
commit
84ac0583d1
@ -10,8 +10,6 @@ import (
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
const maxRetries = 3
|
||||
|
||||
var jikanDB = arn.Node.Namespace("jikan")
|
||||
|
||||
func main() {
|
||||
@ -38,23 +36,17 @@ func main() {
|
||||
func sync(anime *arn.Anime, malID string) {
|
||||
fmt.Printf("%s %s (MAL: %s)\n", anime.ID, anime.Title.Canonical, malID)
|
||||
|
||||
if !jikanDB.Exists("Anime", malID) {
|
||||
var anime *jikan.Anime
|
||||
var err error
|
||||
|
||||
for try := 1; try <= maxRetries; try++ {
|
||||
time.Sleep(time.Second)
|
||||
anime, err = jikan.GetAnime(malID)
|
||||
|
||||
if err == nil {
|
||||
jikanDB.Set("Anime", malID, anime)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Error fetching %s on try %d: %v", malID, try, err)
|
||||
|
||||
// Wait an additional second
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
if jikanDB.Exists("Anime", malID) {
|
||||
return
|
||||
}
|
||||
|
||||
time.Sleep(time.Second)
|
||||
jikanAnime, err := jikan.GetAnime(malID)
|
||||
|
||||
if err == nil {
|
||||
jikanDB.Set("Anime", malID, jikanAnime)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Error fetching %s: %v", malID, err)
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ import (
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
const maxRetries = 3
|
||||
|
||||
var jikanDB = arn.Node.Namespace("jikan")
|
||||
|
||||
func main() {
|
||||
@ -49,23 +47,17 @@ func main() {
|
||||
func fetchCharacter(malCharacterID string) {
|
||||
fmt.Printf("Fetching character ID %s\n", malCharacterID)
|
||||
|
||||
if !jikanDB.Exists("Character", malCharacterID) {
|
||||
var character *jikan.Character
|
||||
var err error
|
||||
|
||||
for try := 1; try <= maxRetries; try++ {
|
||||
time.Sleep(time.Second)
|
||||
character, err = jikan.GetCharacter(malCharacterID)
|
||||
|
||||
if err == nil {
|
||||
jikanDB.Set("Character", malCharacterID, character)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Error fetching %s on try %d: %v", malCharacterID, try, err)
|
||||
|
||||
// Wait an additional second
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
if jikanDB.Exists("Character", malCharacterID) {
|
||||
return
|
||||
}
|
||||
|
||||
time.Sleep(time.Second)
|
||||
character, err := jikan.GetCharacter(malCharacterID)
|
||||
|
||||
if err == nil {
|
||||
jikanDB.Set("Character", malCharacterID, character)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Error fetching %s: %v", malCharacterID, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user