summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Grüneis <gimpf@gimpf.org>2014-10-25 00:26:16 +0200
committerMarkus Grüneis <gimpf@gimpf.org>2014-10-25 00:26:23 +0200
commit404ed197207636bdf73a4bbaabb0a64f215731ad (patch)
treea9dfd980492f5975bb033e0abf3463285c86ec34
parenthub: add hacky untested MySql support (diff)
hub: Add many debug printfs.
-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)
}
}