added stream retry, probably a bad approach

This commit is contained in:
farhan 2020-12-29 16:41:43 +00:00
parent 5473052519
commit 5914fc0890

View File

@ -15,6 +15,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) {
//var client_id string //var client_id string
//var client_secret string //var client_secret string
var oauthData OAuth var oauthData OAuth
var retry bool
for { for {
@ -78,12 +79,13 @@ func StreamMastodon(endpoint string, o *RunningInstance) {
case "data": case "data":
switch name { switch name {
case "update": case "update":
jsoner := token[1][1:] jsondata := token[1][1:]
err := json.Unmarshal([]byte(jsoner), &newpost) err := json.Unmarshal([]byte(jsondata), &newpost)
if err != nil { if err != nil {
continue continue
log.Fatal("Unable to unmarshal with error: ", err) log.Fatal("Unable to unmarshal with error: ", err)
} }
retry = true
default: default:
continue continue
} }
@ -108,7 +110,11 @@ func StreamMastodon(endpoint string, o *RunningInstance) {
ri_mutex.Unlock() ri_mutex.Unlock()
} }
} }
if retry == true {
time.Sleep(time.Minute * 30) time.Sleep(time.Minute * 30)
} else {
break
}
} }
// ri_mutex.Lock() // ri_mutex.Lock()