diff options
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5srv.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srv.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srv.go b/src/hub/src/spreadspace.org/sfive/s5srv.go index 3bfccbe..fd76f1b 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srv.go +++ b/src/hub/src/spreadspace.org/sfive/s5srv.go @@ -32,6 +32,15 @@ type getUpdatesToken struct { response chan getUpdatesResult } +type getHubIdResult struct { + id string + err error +} + +type getHubIdToken struct { + response chan getHubIdResult +} + type StatsSinkServer struct { store sqliteStore quit chan bool @@ -41,6 +50,7 @@ type StatsSinkServer struct { getStatsChan chan queryStatsToken getUpdatesAfterChan chan getUpdatesAfterToken getUpdatesChan chan getUpdatesToken + getHubIdChan chan getHubIdToken } func (self StatsSinkServer) appendActor() { @@ -79,6 +89,9 @@ func (self StatsSinkServer) appendActor() { case token := <-self.getUpdatesChan: values, err := self.store.GetUpdates(token.filter) token.response <- getUpdatesResult{values, err} + case token := <-self.getHubIdChan: + storeId, err := self.store.GetStoreId() + token.response <- getHubIdResult{storeId, err} } } } @@ -111,6 +124,14 @@ func (self StatsSinkServer) getStatsInvoke(filter *StatsFilter) (StatsResult, er return res.stats, res.err } +func (self StatsSinkServer) getHubIdInvoke() (string, error) { + token := getHubIdToken{response: make(chan getHubIdResult, 1)} + defer close(token.response) + self.getHubIdChan <- token + res := <-token.response + return res.id, res.err +} + func (self StatsSinkServer) Close() { self.quit <- true <-self.done @@ -121,6 +142,7 @@ func (self StatsSinkServer) Close() { close(self.getStatsChan) close(self.getUpdatesAfterChan) close(self.getUpdatesChan) + close(self.getHubIdChan) self.store.Close() } @@ -139,6 +161,7 @@ func NewServer(mysql bool, dbPath string) (server *StatsSinkServer, err error) { server.getStatsChan = make(chan queryStatsToken, 5) server.getUpdatesAfterChan = make(chan getUpdatesAfterToken, 1) server.getUpdatesChan = make(chan getUpdatesToken, 3) + server.getHubIdChan = make(chan getHubIdToken, 1) go server.appendActor() return } |