summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForward.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
index b5ff45a..00542a4 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
@@ -67,10 +67,13 @@ tryResync:
lastId, _, err := self.getLastUpdate(baseurl, client)
if err != nil {
+ s5l.Printf("fwd: lastupdate returned err: %v", err)
time.Sleep(5 * time.Second)
continue tryResync
}
+ s5l.Printf("fwd: lastupdate: %d", lastId)
+
nextBatch:
for {
updates, err := self.store.GetUpdatesAfter(lastId)
@@ -80,6 +83,8 @@ tryResync:
continue nextBatch
}
+ s5l.Printf("fwd: got %d updates", len(updates))
+
if len(updates) == 0 {
time.Sleep(1 * time.Second)
continue nextBatch
@@ -91,16 +96,25 @@ tryResync:
s5l.Panicf("fwd: encode failed: %v\n", err)
}
- _, err = client.Post(url, "application/json", bytes.NewBuffer(data))
+ s5l.Printf("fwd: marshal OK")
+
+ resp, err := client.Post(url, "application/json", bytes.NewBuffer(data))
if err != nil {
s5l.Printf("fwd: post failed: %v\n", err)
continue tryResync
// TODO retry etc.
}
+ resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ s5l.Printf("fwd: post failed: %s\n", resp.Status)
+ continue tryResync
+ }
// }
+ s5l.Printf("fwd: post OK")
+
lastId = findMaxId(updates)
- s5tl.Printf("fwd: new lastid: %d", lastId)
+ s5l.Printf("fwd: new lastid: %d", lastId)
time.Sleep(2 * time.Second)
}
}