From 5914fc0890ce127a765f1e661414682a945ba0b5 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Tue, 29 Dec 2020 16:41:43 +0000 Subject: [PATCH] added stream retry, probably a bad approach --- stream.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stream.go b/stream.go index 9aa9d20..1228c36 100644 --- a/stream.go +++ b/stream.go @@ -15,6 +15,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) { //var client_id string //var client_secret string var oauthData OAuth + var retry bool for { @@ -78,12 +79,13 @@ func StreamMastodon(endpoint string, o *RunningInstance) { case "data": switch name { case "update": - jsoner := token[1][1:] - err := json.Unmarshal([]byte(jsoner), &newpost) + jsondata := token[1][1:] + err := json.Unmarshal([]byte(jsondata), &newpost) if err != nil { continue log.Fatal("Unable to unmarshal with error: ", err) } + retry = true default: continue } @@ -108,7 +110,11 @@ func StreamMastodon(endpoint string, o *RunningInstance) { ri_mutex.Unlock() } } - time.Sleep(time.Minute * 30) + if retry == true { + time.Sleep(time.Minute * 30) + } else { + break + } } // ri_mutex.Lock()