From 3a087f5c9816d5dac96690049b630ae8cb1e4238 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 27 Apr 2017 21:06:04 +0200 Subject: rename some stuff --- src/hub/src/spreadspace.org/sfive-hub/s5hub.go | 6 +++--- src/hub/src/spreadspace.org/sfive/s5srv.go | 6 +++--- src/hub/src/spreadspace.org/sfive/s5srvForward.go | 12 ++++++------ src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go | 18 +++++++++--------- .../src/spreadspace.org/sfive/s5srvForwardGraphite.go | 14 +++++++------- src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go | 16 ++++++++-------- src/hub/src/spreadspace.org/sfive/s5srvWeb.go | 2 +- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go index d91d6e9..bd68ff2 100644 --- a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go +++ b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go @@ -121,7 +121,7 @@ func main() { go func() { defer wg.Done() s5hl.Println("starting elastic-search forward") - srv.RunForwardingToElasticSearch(*forwardES) + srv.RunForwardingEs(*forwardES) s5hl.Println("elastic-search forward finished") }() } @@ -131,7 +131,7 @@ func main() { go func() { defer wg.Done() s5hl.Println("starting graphite forward") - srv.RunForwardingToGraphite(*forwardGraphite, *graphiteBasePath) + srv.RunForwardingGraphite(*forwardGraphite, *graphiteBasePath) s5hl.Println("graphite forward finished") }() } @@ -141,7 +141,7 @@ func main() { go func() { defer wg.Done() s5hl.Println("starting piwik forward") - srv.RunForwardingToPiwik(*forwardPiwik, *piwikSiteURL, *piwikSiteID, *piwikToken) + srv.RunForwardingPiwik(*forwardPiwik, *piwikSiteURL, *piwikSiteID, *piwikToken) s5hl.Println("piwik forward finished") }() } diff --git a/src/hub/src/spreadspace.org/sfive/s5srv.go b/src/hub/src/spreadspace.org/sfive/s5srv.go index c43f0ad..26c620f 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srv.go +++ b/src/hub/src/spreadspace.org/sfive/s5srv.go @@ -119,7 +119,7 @@ func (srv Server) appendActor() { } } -func (srv Server) getUpdatesAfterInvoke(id, limit int) ([]DataUpdateFull, error) { +func (srv Server) GetUpdatesAfter(id, limit int) ([]DataUpdateFull, error) { token := getUpdatesAfterToken{id: id, limit: limit, response: make(chan getUpdatesResult, 1)} defer close(token.response) srv.getUpdatesAfterChan <- token @@ -127,7 +127,7 @@ func (srv Server) getUpdatesAfterInvoke(id, limit int) ([]DataUpdateFull, error) return res.values, res.err } -func (srv Server) getHubIdInvoke() string { +func (srv Server) GetHubId() string { token := getHubIdToken{response: make(chan getHubIdResult, 1)} defer close(token.response) srv.getHubIdChan <- token @@ -135,7 +135,7 @@ func (srv Server) getHubIdInvoke() string { return res.id } -func (srv Server) getLastUpdateIdInvoke() (int, error) { +func (srv Server) GetLastUpdateId() (int, error) { token := getLastUpdateIdToken{response: make(chan getLastUpdateIdResult, 1)} defer close(token.response) srv.getLastUpdateIdChan <- token diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go index 45dc9a2..d6874de 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go @@ -52,8 +52,8 @@ func findMaxId(values []DataUpdateFull) int { return maxId } -func (srv Server) getLastUpdate(baseurl string, client *http.Client) (latestId int, storeId string, err error) { - storeId = srv.getHubIdInvoke() +func (srv Server) forwardGetLastUpdate(baseurl string, client *http.Client) (latestId int, storeId string, err error) { + storeId = srv.GetHubId() var resp *http.Response resp, err = client.Get(baseurl + "/lastupdate/" + storeId) @@ -90,11 +90,11 @@ func (srv Server) getLastUpdate(baseurl string, client *http.Client) (latestId i return } -func (srv Server) handleForwarding(baseurl string, client *http.Client) { +func (srv Server) forwardRun(baseurl string, client *http.Client) { url := baseurl + "/updates" tryResync: for { - lastId, _, err := srv.getLastUpdate(baseurl, client) + lastId, _, err := srv.forwardGetLastUpdate(baseurl, client) if err != nil { s5l.Printf("fwd: lastupdate returned err: %v", err) @@ -106,7 +106,7 @@ tryResync: nextBatch: for { - updates, err := srv.getUpdatesAfterInvoke(lastId, 5000) + updates, err := srv.GetUpdatesAfter(lastId, 5000) if err != nil { s5l.Printf("fwd: failed reading updates: %v\n", err) time.Sleep(500 * time.Millisecond) @@ -148,5 +148,5 @@ tryResync: } func (srv Server) RunForwarding(forwardBaseUrl string) { - srv.handleForwarding(forwardBaseUrl, http.DefaultClient) + srv.forwardRun(forwardBaseUrl, http.DefaultClient) } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go index 52493cc..8880b8a 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go @@ -42,17 +42,17 @@ import ( "time" ) -const lastUpdateJson = `{ +const forwardEsLastUpdateJson = `{ "query": {"match": { "SourceHubUuid": "%s" } }, "aggregations": { "last-id" : { "max" : { "field": "SourceHubDataUpdateId" } } } }` -func (srv Server) getLastUpdateEs(baseurl string, client *http.Client) (latestId int, storeId string, err error) { +func (srv Server) forwardEsGetLastUpdate(baseurl string, client *http.Client) (latestId int, storeId string, err error) { url := baseurl + "/dataupdate/_search?search_type=count" - storeId = srv.getHubIdInvoke() + storeId = srv.GetHubId() - queryJson := fmt.Sprintf(lastUpdateJson, storeId) + queryJson := fmt.Sprintf(forwardEsLastUpdateJson, storeId) s5dl.Printf("fwd-es: query: %s", queryJson) var resp *http.Response @@ -100,11 +100,11 @@ func (srv Server) getLastUpdateEs(baseurl string, client *http.Client) (latestId return } -func (srv Server) handleForwardingToElasticSearch(baseurl string, client *http.Client) { +func (srv Server) forwardEsRun(baseurl string, client *http.Client) { url := baseurl + "/_bulk" tryResync: for { - lastId, _, err := srv.getLastUpdateEs(baseurl, client) + lastId, _, err := srv.forwardEsGetLastUpdate(baseurl, client) if err != nil { s5l.Printf("fwd-es: lastupdate returned err: %v", err) time.Sleep(5 * time.Second) @@ -114,7 +114,7 @@ tryResync: nextBatch: for { - updates, err := srv.getUpdatesAfterInvoke(lastId, 5000) + updates, err := srv.GetUpdatesAfter(lastId, 5000) if err != nil { s5l.Printf("fwd-es: failed reading updates: %v\n", err) time.Sleep(500 * time.Millisecond) @@ -165,6 +165,6 @@ tryResync: } } -func (srv Server) RunForwardingToElasticSearch(forwardBaseUrl string) { - srv.handleForwardingToElasticSearch(forwardBaseUrl, http.DefaultClient) +func (srv Server) RunForwardingEs(forwardBaseUrl string) { + srv.forwardEsRun(forwardBaseUrl, http.DefaultClient) } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go index ede66d2..2c0043b 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go @@ -39,8 +39,8 @@ import ( "github.com/equinox0815/graphite-golang" ) -func (srv Server) getLastUpdateGraphite(conn *graphite.Graphite) (latestId int, storeId string, err error) { - latestId, err = srv.getLastUpdateIdInvoke() +func (srv Server) forwardGraphiteGetLastUpdate(conn *graphite.Graphite) (latestId int, storeId string, err error) { + latestId, err = srv.GetLastUpdateId() if err != nil { s5l.Printf("fwd-graphite: failed to get own hubid: %v\n", err) return @@ -49,7 +49,7 @@ func (srv Server) getLastUpdateGraphite(conn *graphite.Graphite) (latestId int, return } -func (srv Server) handleForwardingToGraphite(forwardHost string, basePath string) { +func (srv Server) forwardGraphiteRun(forwardHost string, basePath string) { tryResync: for { client, err := graphite.NewGraphiteFromAddress(forwardHost) @@ -59,7 +59,7 @@ tryResync: continue tryResync } - lastId, _, err := srv.getLastUpdateGraphite(client) + lastId, _, err := srv.forwardGraphiteGetLastUpdate(client) if err != nil { s5l.Printf("fwd-graphite: lastupdate returned err: %v", err) client.Disconnect() @@ -70,7 +70,7 @@ tryResync: nextBatch: for { - updates, err := srv.getUpdatesAfterInvoke(lastId, 5000) + updates, err := srv.GetUpdatesAfter(lastId, 5000) if err != nil { s5l.Printf("fwd-graphite: failed reading updates: %v\n", err) time.Sleep(500 * time.Millisecond) @@ -111,6 +111,6 @@ tryResync: } } -func (srv Server) RunForwardingToGraphite(forwardHost string, basePath string) { - srv.handleForwardingToGraphite(forwardHost, basePath) +func (srv Server) RunForwardingGraphite(forwardHost string, basePath string) { + srv.forwardGraphiteRun(forwardHost, basePath) } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go index ab45f7c..3d44500 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go @@ -44,12 +44,12 @@ import ( "time" ) -type PiwikBulkRequest struct { +type forwardPiwikBulkRequest struct { Requests []string `json:"requests"` TokenAuth string `json:"token_auth"` } -func (srv Server) getLastUpdatePiwik(piwikURL, siteURL string, siteID uint, token string, client *http.Client) (latestId int, storeId string, err error) { +func (srv Server) forwardPiwikGetLastUpdate(piwikURL, siteURL string, siteID uint, token string, client *http.Client) (latestId int, storeId string, err error) { // TODO: ask piwik what the last update was... latestId, err = 0, nil //srv.getLastUpdateIdInvoke() @@ -61,10 +61,10 @@ func (srv Server) getLastUpdatePiwik(piwikURL, siteURL string, siteID uint, toke return } -func (srv Server) handleForwardingToPiwik(piwikURL, siteURL string, siteID uint, token string, client *http.Client) { +func (srv Server) forwardPiwikRun(piwikURL, siteURL string, siteID uint, token string, client *http.Client) { tryResync: for { - lastId, _, err := srv.getLastUpdatePiwik(piwikURL, siteURL, siteID, token, client) + lastId, _, err := srv.forwardPiwikGetLastUpdate(piwikURL, siteURL, siteID, token, client) if err != nil { s5l.Printf("fwd-piwik: lastupdate returned err: %v", err) time.Sleep(5 * time.Second) @@ -74,7 +74,7 @@ tryResync: nextBatch: for { - updates, err := srv.getUpdatesAfterInvoke(lastId, 5000) + updates, err := srv.GetUpdatesAfter(lastId, 5000) if err != nil { s5l.Printf("fwd-piwik: failed reading updates: %v\n", err) time.Sleep(500 * time.Millisecond) @@ -88,7 +88,7 @@ tryResync: continue nextBatch } - req := PiwikBulkRequest{TokenAuth: token} + req := forwardPiwikBulkRequest{TokenAuth: token} for _, update := range updates { if len(update.Data.Clients) == 0 { continue @@ -137,6 +137,6 @@ tryResync: } } -func (srv Server) RunForwardingToPiwik(piwikURL, siteURL string, siteID uint, piwikToken string) { - srv.handleForwardingToPiwik(piwikURL, siteURL, siteID, piwikToken, http.DefaultClient) +func (srv Server) RunForwardingPiwik(piwikURL, siteURL string, siteID uint, piwikToken string) { + srv.forwardPiwikRun(piwikURL, siteURL, siteID, piwikToken, http.DefaultClient) } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go index 3bd5e7a..acf61a4 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go @@ -89,7 +89,7 @@ func (srv Server) webGetSource(c web.C, w http.ResponseWriter, r *http.Request) func (srv Server) webGetUpdateList(c web.C, w http.ResponseWriter, r *http.Request) { const resourceName = "updates" - values, err := srv.getUpdatesAfterInvoke(-1, 3) // TODO: get start and limit from param + values, err := srv.GetUpdatesAfter(-1, 3) // TODO: get start and limit from param if err != nil { http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError) return -- cgit v1.2.3