From 6e6ef6f437706cce265352a034dd19e0039e149e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 10 Mar 2018 04:42:22 +0100 Subject: fix bug in forwarder id handling --- src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go | 8 ++++---- src/hub/src/spreadspace.org/sfive/s5srvForwardSfive.go | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go index 93b717b..aac94e1 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go @@ -49,17 +49,17 @@ type forwardPiwikBulkRequest struct { TokenAuth string `json:"token_auth"` } -func fwdPiwikGetLastUpdateID(piwikURL, siteURL string, siteID uint, token string, client *http.Client, hubUuid string) (lastID int, err error) { +func fwdPiwikGetLastUpdateID(piwikURL, siteURL string, siteID uint, token string, client *http.Client, hubUUID string) (lastID int64, err error) { // TODO: ask piwik what the last update was... lastID = 0 return } func (srv *Server) forwardPiwikRun(piwikURL, siteURL string, siteID uint, token string, client *http.Client) { - // hubUuid := srv.store.GetHubUuid() + // hubUUID := srv.store.GetHubUUID() tryResync: for { - // lastID, err := srv.forwardPiwikGetLastUpdateID(piwikURL, siteURL, siteID, token, client, hubUuid) + // lastID, err := fwdPiwikGetLastUpdateID(piwikURL, siteURL, siteID, token, client, hubUUID) lastID, err := srv.store.GetLastUpdateID() if err != nil { s5l.Printf("srv|fwd-piwik: fetching lastupdate failed: %v", err) @@ -70,7 +70,7 @@ tryResync: nextBatch: for { - updates, err := srv.store.GetUpdatesAfter(lastID, 5000) + updates, err := srv.store.GetUpdatesAfter(lastID, 500) if err != nil { s5l.Printf("srv|fwd-piwik: reading updates failed: %v", err) time.Sleep(500 * time.Millisecond) diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardSfive.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardSfive.go index 0e0a7e6..0c9c82c 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForwardSfive.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardSfive.go @@ -44,7 +44,11 @@ import ( func findMaxID(updates []*UpdateFull) int64 { maxID := int64(-1) for _, value := range updates { - if id := value.SourceHubUpdateID; id > maxID { + id := value.SourceHubUpdateID + if value.ForwardHubUUID != "" { // we are not the source but the forwarder + id = value.ForwardHubUpdateID + } + if id > maxID { maxID = id } } -- cgit v1.2.3