summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srv.go28
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForward.go10
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvWeb.go10
3 files changed, 29 insertions, 19 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srv.go b/src/hub/src/spreadspace.org/sfive/s5srv.go
index 15806d9..3bfccbe 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srv.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srv.go
@@ -83,6 +83,34 @@ func (self StatsSinkServer) appendActor() {
}
}
+func (self StatsSinkServer) getUpdatesAfterInvoke(id int) (values []StatisticsData, err error) {
+ token := getUpdatesAfterToken{id: id, response: make(chan getUpdatesResult, 1)}
+ defer close(token.response)
+ self.getUpdatesAfterChan <- token
+ res := <-token.response
+ values = res.values
+ err = res.err
+ return
+}
+
+func (self StatsSinkServer) getUpdatesInvoke(filter *StatsFilter) (values []StatisticsData, err error) {
+ token := getUpdatesToken{filter: filter, response: make(chan getUpdatesResult, 1)}
+ defer close(token.response)
+ self.getUpdatesChan <- token
+ res := <-token.response
+ values = res.values
+ err = res.err
+ return
+}
+
+func (self StatsSinkServer) getStatsInvoke(filter *StatsFilter) (StatsResult, error) {
+ token := queryStatsToken{filter: filter, response: make(chan queryStatsResult, 1)}
+ defer close(token.response)
+ self.getStatsChan <- token
+ res := <-token.response
+ return res.stats, res.err
+}
+
func (self StatsSinkServer) Close() {
self.quit <- true
<-self.done
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
index 39dda24..2dddf60 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
@@ -60,16 +60,6 @@ func (self StatsSinkServer) getLastUpdate(baseurl string, client *http.Client) (
return
}
-func (self StatsSinkServer) getUpdatesAfterInvoke(id int) (values []StatisticsData, err error) {
- token := getUpdatesAfterToken{id: id, response: make(chan getUpdatesResult, 1)}
- defer close(token.response)
- self.getUpdatesAfterChan <- token
- res := <-token.response
- values = res.values
- err = res.err
- return
-}
-
func (self StatsSinkServer) handleForwarding(baseurl string, client *http.Client) {
url := baseurl + "/updates"
tryResync:
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
index d657f8b..d380de1 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
@@ -197,15 +197,7 @@ func (self StatsSinkServer) getLastUpdateIdForUuid(c web.C, w http.ResponseWrite
func (self StatsSinkServer) getStats(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "stats"
filter := getFilter(r)
-
- token := queryStatsToken{filter: &filter, response: make(chan queryStatsResult, 1)}
- defer close(token.response)
- self.getStatsChan <- token
- res := <-token.response
- values := res.stats
- err := res.err
-
- // values, err := self.store.GetStats(&filter)
+ values, err := self.getStatsInvoke(&filter)
if err != nil {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError)