summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2017-04-27 05:09:24 +0200
committerChristian Pointner <equinox@spreadspace.org>2017-04-27 05:09:24 +0200
commit5e95861eb81e45ebb7b58de6f31cde929dde8211 (patch)
tree611bb44be34a3e97a8f1838501e53dfdcc4e89c5
parentstoring data updates into bolt works now (diff)
no more self
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5cvt.go8
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srv.go70
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForward.go14
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go14
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go14
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go14
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvPipe.go16
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvWeb.go52
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5typesApi.go18
9 files changed, 110 insertions, 110 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5cvt.go b/src/hub/src/spreadspace.org/sfive/s5cvt.go
index 12c0562..dd326fb 100644
--- a/src/hub/src/spreadspace.org/sfive/s5cvt.go
+++ b/src/hub/src/spreadspace.org/sfive/s5cvt.go
@@ -38,20 +38,20 @@ func NewPlainDecoder() FullDecoder {
return new(PlainDecoder)
}
-func (self *StatefulDecoder) Decode(jsonString []byte) (dat DataUpdateFull, err error) {
- dat.CopyFromSourceId(&self.sourceId)
+func (sd *StatefulDecoder) Decode(jsonString []byte) (dat DataUpdateFull, err error) {
+ dat.CopyFromSourceId(&sd.sourceId)
err = json.Unmarshal(jsonString, &dat)
// like in PlainDecoder, let the client decide how to use partial results
// (Unmarshal returns partial results in case of errors)
return
}
-func (self *PlainDecoder) Decode(jsonString []byte) (dat DataUpdateFull, err error) {
+func (pd *PlainDecoder) Decode(jsonString []byte) (dat DataUpdateFull, err error) {
err = json.Unmarshal(jsonString, &dat)
return
}
-func (self *PlainEncoder) Encode(data *DataUpdateFull) []byte {
+func (pe *PlainEncoder) Encode(data *DataUpdateFull) []byte {
res, err := json.Marshal(data)
if err != nil {
s5l.Panicln("failed to encode DataUpdateFull")
diff --git a/src/hub/src/spreadspace.org/sfive/s5srv.go b/src/hub/src/spreadspace.org/sfive/s5srv.go
index 047a318..ac3e086 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srv.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srv.go
@@ -52,16 +52,16 @@ type Server struct {
getLastUpdateIdChan chan getLastUpdateIdToken
}
-func (self Server) appendActor() {
- defer func() { self.done <- true }()
+func (srv Server) appendActor() {
+ defer func() { srv.done <- true }()
for {
select {
- case <-self.quit:
+ case <-srv.quit:
return
- case value := <-self.appendData:
+ case value := <-srv.appendData:
var err error
for tryNum := 0; tryNum < 5; tryNum++ {
- err = self.store.Append(value)
+ err = srv.store.Append(value)
if err != nil {
time.Sleep(1 * time.Second)
} else {
@@ -71,73 +71,73 @@ func (self Server) appendActor() {
if err != nil {
s5l.Printf("failed to store data: %v\n", err)
}
- case token := <-self.appendManyData:
- err := self.store.AppendMany(token.data)
+ case token := <-srv.appendManyData:
+ err := srv.store.AppendMany(token.data)
if err != nil {
s5l.Printf("failed to store many data: %v\n", err)
token.response <- false
} else {
token.response <- true
}
- case token := <-self.getUpdatesAfterChan:
- values, err := self.store.GetUpdatesAfter(token.id)
+ case token := <-srv.getUpdatesAfterChan:
+ values, err := srv.store.GetUpdatesAfter(token.id)
token.response <- getUpdatesResult{values, err}
- case token := <-self.getUpdatesChan:
- values, err := self.store.GetUpdates()
+ case token := <-srv.getUpdatesChan:
+ values, err := srv.store.GetUpdates()
token.response <- getUpdatesResult{values, err}
- case token := <-self.getHubIdChan:
- token.response <- getHubIdResult{self.store.GetStoreId()}
- case token := <-self.getLastUpdateIdChan:
- lastUpdateId, err := self.store.GetLastUpdateId()
+ case token := <-srv.getHubIdChan:
+ token.response <- getHubIdResult{srv.store.GetStoreId()}
+ case token := <-srv.getLastUpdateIdChan:
+ lastUpdateId, err := srv.store.GetLastUpdateId()
token.response <- getLastUpdateIdResult{lastUpdateId, err}
}
}
}
-func (self Server) getUpdatesAfterInvoke(id int) ([]DataUpdateFull, error) {
+func (srv Server) getUpdatesAfterInvoke(id int) ([]DataUpdateFull, error) {
token := getUpdatesAfterToken{id: id, response: make(chan getUpdatesResult, 1)}
defer close(token.response)
- self.getUpdatesAfterChan <- token
+ srv.getUpdatesAfterChan <- token
res := <-token.response
return res.values, res.err
}
-func (self Server) getUpdatesInvoke() ([]DataUpdateFull, error) {
+func (srv Server) getUpdatesInvoke() ([]DataUpdateFull, error) {
token := getUpdatesToken{response: make(chan getUpdatesResult, 1)}
defer close(token.response)
- self.getUpdatesChan <- token
+ srv.getUpdatesChan <- token
res := <-token.response
return res.values, res.err
}
-func (self Server) getHubIdInvoke() string {
+func (srv Server) getHubIdInvoke() string {
token := getHubIdToken{response: make(chan getHubIdResult, 1)}
defer close(token.response)
- self.getHubIdChan <- token
+ srv.getHubIdChan <- token
res := <-token.response
return res.id
}
-func (self Server) getLastUpdateIdInvoke() (int, error) {
+func (srv Server) getLastUpdateIdInvoke() (int, error) {
token := getLastUpdateIdToken{response: make(chan getLastUpdateIdResult, 1)}
defer close(token.response)
- self.getLastUpdateIdChan <- token
+ srv.getLastUpdateIdChan <- token
res := <-token.response
return res.id, res.err
}
-func (self Server) Close() {
- self.quit <- true
- <-self.done
- close(self.quit)
- close(self.done)
- close(self.appendData)
- close(self.appendManyData)
- close(self.getUpdatesAfterChan)
- close(self.getUpdatesChan)
- close(self.getHubIdChan)
- close(self.getLastUpdateIdChan)
- self.store.Close()
+func (srv Server) Close() {
+ srv.quit <- true
+ <-srv.done
+ close(srv.quit)
+ close(srv.done)
+ close(srv.appendData)
+ close(srv.appendManyData)
+ close(srv.getUpdatesAfterChan)
+ close(srv.getUpdatesChan)
+ close(srv.getHubIdChan)
+ close(srv.getLastUpdateIdChan)
+ srv.store.Close()
}
func NewServer(dbPath string) (server *Server, err error) {
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
index abb00fb..6c9823f 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
@@ -20,8 +20,8 @@ func findMaxId(values []DataUpdateFull) int {
return maxId
}
-func (self Server) getLastUpdate(baseurl string, client *http.Client) (latestId int, storeId string, err error) {
- storeId = self.getHubIdInvoke()
+func (srv Server) getLastUpdate(baseurl string, client *http.Client) (latestId int, storeId string, err error) {
+ storeId = srv.getHubIdInvoke()
var resp *http.Response
resp, err = client.Get(baseurl + "/lastupdate/" + storeId)
@@ -58,11 +58,11 @@ func (self Server) getLastUpdate(baseurl string, client *http.Client) (latestId
return
}
-func (self Server) handleForwarding(baseurl string, client *http.Client) {
+func (srv Server) handleForwarding(baseurl string, client *http.Client) {
url := baseurl + "/updates"
tryResync:
for {
- lastId, _, err := self.getLastUpdate(baseurl, client)
+ lastId, _, err := srv.getLastUpdate(baseurl, client)
if err != nil {
s5l.Printf("fwd: lastupdate returned err: %v", err)
@@ -74,7 +74,7 @@ tryResync:
nextBatch:
for {
- updates, err := self.getUpdatesAfterInvoke(lastId)
+ updates, err := srv.getUpdatesAfterInvoke(lastId)
if err != nil {
s5l.Printf("fwd: failed reading updates: %v\n", err)
time.Sleep(500 * time.Millisecond)
@@ -116,6 +116,6 @@ tryResync:
}
}
-func (self Server) RunForwarding(forwardBaseUrl string) {
- self.handleForwarding(forwardBaseUrl, http.DefaultClient)
+func (srv Server) RunForwarding(forwardBaseUrl string) {
+ srv.handleForwarding(forwardBaseUrl, http.DefaultClient)
}
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go
index 4a4c838..622b307 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardEs.go
@@ -15,10 +15,10 @@ const lastUpdateJson = `{
"aggregations": { "last-id" : { "max" : { "field": "SourceHubDataUpdateId" } } }
}`
-func (self Server) getLastUpdateEs(baseurl string, client *http.Client) (latestId int, storeId string, err error) {
+func (srv Server) getLastUpdateEs(baseurl string, client *http.Client) (latestId int, storeId string, err error) {
url := baseurl + "/dataupdate/_search?search_type=count"
- storeId = self.getHubIdInvoke()
+ storeId = srv.getHubIdInvoke()
queryJson := fmt.Sprintf(lastUpdateJson, storeId)
s5tl.Printf("fwd-es: query: %s", queryJson)
@@ -68,11 +68,11 @@ func (self Server) getLastUpdateEs(baseurl string, client *http.Client) (latestI
return
}
-func (self Server) handleForwardingToElasticSearch(baseurl string, client *http.Client) {
+func (srv Server) handleForwardingToElasticSearch(baseurl string, client *http.Client) {
url := baseurl + "/_bulk"
tryResync:
for {
- lastId, _, err := self.getLastUpdateEs(baseurl, client)
+ lastId, _, err := srv.getLastUpdateEs(baseurl, client)
if err != nil {
s5l.Printf("fwd-es: lastupdate returned err: %v", err)
time.Sleep(5 * time.Second)
@@ -82,7 +82,7 @@ tryResync:
nextBatch:
for {
- updates, err := self.getUpdatesAfterInvoke(lastId)
+ updates, err := srv.getUpdatesAfterInvoke(lastId)
if err != nil {
s5l.Printf("fwd-es: failed reading updates: %v\n", err)
time.Sleep(500 * time.Millisecond)
@@ -136,6 +136,6 @@ tryResync:
}
}
-func (self Server) RunForwardingToElasticSearch(forwardBaseUrl string) {
- self.handleForwardingToElasticSearch(forwardBaseUrl, http.DefaultClient)
+func (srv Server) RunForwardingToElasticSearch(forwardBaseUrl string) {
+ srv.handleForwardingToElasticSearch(forwardBaseUrl, http.DefaultClient)
}
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go
index 42c16bc..8ab0ac6 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardGraphite.go
@@ -7,8 +7,8 @@ import (
"github.com/equinox0815/graphite-golang"
)
-func (self Server) getLastUpdateGraphite(conn *graphite.Graphite) (latestId int, storeId string, err error) {
- latestId, err = self.getLastUpdateIdInvoke()
+func (srv Server) getLastUpdateGraphite(conn *graphite.Graphite) (latestId int, storeId string, err error) {
+ latestId, err = srv.getLastUpdateIdInvoke()
if err != nil {
s5l.Printf("fwd-graphite: failed to get own hubid: %v\n", err)
return
@@ -17,7 +17,7 @@ func (self Server) getLastUpdateGraphite(conn *graphite.Graphite) (latestId int,
return
}
-func (self Server) handleForwardingToGraphite(forwardHost string, basePath string) {
+func (srv Server) handleForwardingToGraphite(forwardHost string, basePath string) {
tryResync:
for {
client, err := graphite.NewGraphiteFromAddress(forwardHost)
@@ -27,7 +27,7 @@ tryResync:
continue tryResync
}
- lastId, _, err := self.getLastUpdateGraphite(client)
+ lastId, _, err := srv.getLastUpdateGraphite(client)
if err != nil {
s5l.Printf("fwd-graphite: lastupdate returned err: %v", err)
client.Disconnect()
@@ -38,7 +38,7 @@ tryResync:
nextBatch:
for {
- updates, err := self.getUpdatesAfterInvoke(lastId)
+ updates, err := srv.getUpdatesAfterInvoke(lastId)
if err != nil {
s5l.Printf("fwd-graphite: failed reading updates: %v\n", err)
time.Sleep(500 * time.Millisecond)
@@ -80,6 +80,6 @@ tryResync:
}
}
-func (self Server) RunForwardingToGraphite(forwardHost string, basePath string) {
- self.handleForwardingToGraphite(forwardHost, basePath)
+func (srv Server) RunForwardingToGraphite(forwardHost string, basePath string) {
+ srv.handleForwardingToGraphite(forwardHost, basePath)
}
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go b/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go
index 55e67e1..a7566a8 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForwardPiwik.go
@@ -17,10 +17,10 @@ type PiwikBulkRequest struct {
TokenAuth string `json:"token_auth"`
}
-func (self Server) getLastUpdatePiwik(piwikURL, siteURL string, siteID uint, token string, client *http.Client) (latestId int, storeId string, err error) {
+func (srv Server) getLastUpdatePiwik(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 //self.getLastUpdateIdInvoke()
+ latestId, err = 0, nil //srv.getLastUpdateIdInvoke()
if err != nil {
s5l.Printf("fwd-piwik: failed to get own hubid: %v\n", err)
return
@@ -29,10 +29,10 @@ func (self Server) getLastUpdatePiwik(piwikURL, siteURL string, siteID uint, tok
return
}
-func (self Server) handleForwardingToPiwik(piwikURL, siteURL string, siteID uint, token string, client *http.Client) {
+func (srv Server) handleForwardingToPiwik(piwikURL, siteURL string, siteID uint, token string, client *http.Client) {
tryResync:
for {
- lastId, _, err := self.getLastUpdatePiwik(piwikURL, siteURL, siteID, token, client)
+ lastId, _, err := srv.getLastUpdatePiwik(piwikURL, siteURL, siteID, token, client)
if err != nil {
s5l.Printf("fwd-piwik: lastupdate returned err: %v", err)
time.Sleep(5 * time.Second)
@@ -42,7 +42,7 @@ tryResync:
nextBatch:
for {
- updates, err := self.getUpdatesAfterInvoke(lastId)
+ updates, err := srv.getUpdatesAfterInvoke(lastId)
if err != nil {
s5l.Printf("fwd-piwik: failed reading updates: %v\n", err)
time.Sleep(500 * time.Millisecond)
@@ -106,6 +106,6 @@ tryResync:
}
}
-func (self Server) RunForwardingToPiwik(piwikURL, siteURL string, siteID uint, piwikToken string) {
- self.handleForwardingToPiwik(piwikURL, siteURL, siteID, piwikToken, http.DefaultClient)
+func (srv Server) RunForwardingToPiwik(piwikURL, siteURL string, siteID uint, piwikToken string) {
+ srv.handleForwardingToPiwik(piwikURL, siteURL, siteID, piwikToken, http.DefaultClient)
}
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvPipe.go b/src/hub/src/spreadspace.org/sfive/s5srvPipe.go
index 1a4d6a2..9744e38 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvPipe.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvPipe.go
@@ -6,7 +6,7 @@ import (
"net"
)
-func (self Server) handleConnection(conn net.Conn) {
+func (srv Server) handleConnection(conn net.Conn) {
reader := bufio.NewReader(conn)
buffer, err := reader.ReadBytes('\n')
if err != nil {
@@ -38,11 +38,11 @@ func (self Server) handleConnection(conn net.Conn) {
continue
}
- self.appendData <- value
+ srv.appendData <- value
}
}
-func (self Server) handlePacketConn(pconn net.PacketConn) {
+func (srv Server) handlePacketConn(pconn net.PacketConn) {
decoder := NewPlainDecoder()
buffer := make([]byte, 64*1024)
for {
@@ -54,14 +54,14 @@ func (self Server) handlePacketConn(pconn net.PacketConn) {
data := buffer[0:n]
value, err := decoder.Decode(data)
if err == nil {
- self.appendData <- value
+ srv.appendData <- value
} else {
s5l.Printf("p-pipe: failed to decode message: %v\n", err)
}
}
}
-func (self Server) ServePipe(pipePath string) {
+func (srv Server) ServePipe(pipePath string) {
ln, err := net.Listen("unix", pipePath)
if err != nil {
s5l.Printf("pipe: failed to connect: %v", err)
@@ -76,11 +76,11 @@ func (self Server) ServePipe(pipePath string) {
// ignore
continue
}
- go self.handleConnection(conn)
+ go srv.handleConnection(conn)
}
}
-func (self Server) ServeGramPipe(pipePath string) {
+func (srv Server) ServeGramPipe(pipePath string) {
pconn, err := net.ListenPacket("unixgram", pipePath)
if err != nil {
s5l.Printf("p-pipe: failed to listen: %v", err)
@@ -88,5 +88,5 @@ func (self Server) ServeGramPipe(pipePath string) {
}
defer pconn.Close()
- self.handlePacketConn(pconn)
+ srv.handlePacketConn(pconn)
}
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
index 6d3af91..6e2cf00 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
@@ -12,14 +12,14 @@ import (
"github.com/zenazn/goji/web"
)
-func (self Server) healthz(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) healthz(c web.C, w http.ResponseWriter, r *http.Request) {
// TODO: do a more sophisticated check
- fmt.Fprintf(w, "%s\n", self.store.GetStoreId())
+ fmt.Fprintf(w, "%s\n", srv.store.GetStoreId())
}
-func (self Server) getSourcesList(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) getSourcesList(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "sources"
- values, err := self.store.GetSources()
+ values, err := srv.store.GetSources()
if err != nil {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError)
return
@@ -32,14 +32,14 @@ func (self Server) getSourcesList(c web.C, w http.ResponseWriter, r *http.Reques
fmt.Fprintf(w, "%s", jsonString)
}
-func (self Server) getSource(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) getSource(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "source"
id, err := strconv.ParseInt(c.URLParams["id"], 10, 64)
if err != nil {
http.Error(w, fmt.Sprintf("invalid id: %s: %v", resourceName, err), http.StatusBadRequest)
return
}
- value, err := self.store.GetSource(int(id))
+ value, err := srv.store.GetSource(int(id))
if err != nil {
if err == ErrNotFound {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusNotFound)
@@ -56,9 +56,9 @@ func (self Server) getSource(c web.C, w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", jsonString)
}
-func (self Server) getUpdateList(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) getUpdateList(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "updates"
- values, err := self.getUpdatesInvoke()
+ values, err := srv.getUpdatesInvoke()
if err != nil {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError)
return
@@ -71,14 +71,14 @@ func (self Server) getUpdateList(c web.C, w http.ResponseWriter, r *http.Request
fmt.Fprintf(w, "%s", jsonString)
}
-func (self Server) getUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) getUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "update"
id, err := strconv.ParseInt(c.URLParams["id"], 10, 64)
if err != nil {
http.Error(w, fmt.Sprintf("invalid id: %s: %v", resourceName, err), http.StatusBadRequest)
return
}
- value, err := self.store.GetUpdate(int(id))
+ value, err := srv.store.GetUpdate(int(id))
if err != nil {
if err == ErrNotFound {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusNotFound)
@@ -95,7 +95,7 @@ func (self Server) getUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", jsonString)
}
-func (self Server) postUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) postUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "update"
decoder := NewPlainDecoder()
@@ -113,7 +113,7 @@ func (self Server) postUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
data: container.Data,
response: make(chan bool, 2)}
defer close(token.response)
- self.appendManyData <- token
+ srv.appendManyData <- token
success := <-token.response
if !success {
http.Error(w, "failed to store data", http.StatusInternalServerError)
@@ -129,13 +129,13 @@ func (self Server) postUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
return
}
- self.appendData <- data
+ srv.appendData <- data
// TODO send response channel, wait for OK
}
-func (self Server) getLastUpdateId(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) getLastUpdateId(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "lastupdateid"
- value, err := self.store.GetLastUpdateId()
+ value, err := srv.store.GetLastUpdateId()
if err != nil {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError)
return
@@ -143,10 +143,10 @@ func (self Server) getLastUpdateId(c web.C, w http.ResponseWriter, r *http.Reque
fmt.Fprintf(w, "%d", value)
}
-func (self Server) getLastUpdateIdForUuid(c web.C, w http.ResponseWriter, r *http.Request) {
+func (srv Server) getLastUpdateIdForUuid(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "lastupdateid"
id := c.URLParams["id"]
- value, err := self.store.GetLastUpdateForUuid(id)
+ value, err := srv.store.GetLastUpdateForUuid(id)
if err != nil {
http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError)
return
@@ -154,7 +154,7 @@ func (self Server) getLastUpdateIdForUuid(c web.C, w http.ResponseWriter, r *htt
fmt.Fprintf(w, "%d", value)
}
-func (self Server) ServeWeb(vizAppLocation string) {
+func (srv Server) ServeWeb(vizAppLocation string) {
if _, err := os.Stat(vizAppLocation); err != nil {
if os.IsNotExist(err) {
s5l.Panicf("web: viz-app at %s does not exist.", vizAppLocation)
@@ -163,14 +163,14 @@ func (self Server) ServeWeb(vizAppLocation string) {
}
}
- goji.Get("/healthz", self.healthz)
- goji.Get("/sources", self.getSourcesList)
- goji.Get("/sources/:id", self.getSource)
- goji.Get("/updates", self.getUpdateList)
- goji.Get("/updates/:id", self.getUpdate)
- goji.Post("/updates", self.postUpdate)
- goji.Get("/lastupdate", self.getLastUpdateId)
- goji.Get("/lastupdate/:id", self.getLastUpdateIdForUuid)
+ goji.Get("/healthz", srv.healthz)
+ goji.Get("/sources", srv.getSourcesList)
+ goji.Get("/sources/:id", srv.getSource)
+ goji.Get("/updates", srv.getUpdateList)
+ goji.Get("/updates/:id", srv.getUpdate)
+ goji.Post("/updates", srv.postUpdate)
+ goji.Get("/lastupdate", srv.getLastUpdateId)
+ goji.Get("/lastupdate/:id", srv.getLastUpdateIdForUuid)
goji.Handle("/viz/*", http.StripPrefix("/viz/", http.FileServer(http.Dir(vizAppLocation))))
goji.Serve()
diff --git a/src/hub/src/spreadspace.org/sfive/s5typesApi.go b/src/hub/src/spreadspace.org/sfive/s5typesApi.go
index ae99b03..5ac368f 100644
--- a/src/hub/src/spreadspace.org/sfive/s5typesApi.go
+++ b/src/hub/src/spreadspace.org/sfive/s5typesApi.go
@@ -55,15 +55,15 @@ type DataUpdateFullContainer struct {
Data []DataUpdateFull `json:"data"`
}
-func (self *DataUpdateFull) CopyFromSourceId(id *SourceId) {
- self.Hostname = id.Hostname
- self.StreamId = id.StreamId
- self.Tags = id.Tags
- self.Version = id.Version
+func (duf *DataUpdateFull) CopyFromSourceId(src *SourceId) {
+ duf.Hostname = src.Hostname
+ duf.StreamId = src.StreamId
+ duf.Tags = src.Tags
+ duf.Version = src.Version
}
-func (self *DataUpdateFull) CopyFromUpdate(id *DataUpdate) {
- self.StartTime = id.StartTime
- self.Duration = id.Duration
- self.Data = id.Data
+func (duf *DataUpdateFull) CopyFromUpdate(du *DataUpdate) {
+ duf.StartTime = du.StartTime
+ duf.Duration = du.Duration
+ duf.Data = du.Data
}