summaryrefslogtreecommitdiff
path: root/src/hub
diff options
context:
space:
mode:
Diffstat (limited to 'src/hub')
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvWeb.go16
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5store.go12
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5store_test.go9
-rwxr-xr-xsrc/hub/test-fwd2
-rwxr-xr-xsrc/hub/test-fwd-es2
-rwxr-xr-xsrc/hub/test-fwd-piwik2
6 files changed, 40 insertions, 3 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
index 8ecb673..fd7e214 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
@@ -48,6 +48,21 @@ func (srv Server) webHealthz(c web.C, w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s\n", srv.GetHubId())
}
+func (srv Server) webGetHubsList(c web.C, w http.ResponseWriter, r *http.Request) {
+ const resourceName = "hubs"
+ values, err := srv.store.GetHubs()
+ if err != nil {
+ http.Error(w, fmt.Sprintf("failed to retrieve %s: %v", resourceName, err), http.StatusInternalServerError)
+ return
+ }
+ jsonString, err := json.Marshal(GenericDataContainer{values})
+ if err != nil {
+ http.Error(w, fmt.Sprintf("failed to marshal %s: %v", resourceName, err), http.StatusInternalServerError)
+ return
+ }
+ fmt.Fprintf(w, "%s", jsonString)
+}
+
func (srv Server) webGetSourcesList(c web.C, w http.ResponseWriter, r *http.Request) {
const resourceName = "sources"
values, err := srv.store.GetSources()
@@ -187,6 +202,7 @@ func (srv Server) webGetLastUpdateIdForUuid(c web.C, w http.ResponseWriter, r *h
func (srv Server) ServeWeb() {
goji.Get("/healthz", srv.webHealthz)
+ goji.Get("/hubs", srv.webGetHubsList)
goji.Get("/sources", srv.webGetSourcesList)
goji.Get("/sources/:id", srv.webGetSource)
goji.Get("/updates", srv.webGetUpdateList)
diff --git a/src/hub/src/spreadspace.org/sfive/s5store.go b/src/hub/src/spreadspace.org/sfive/s5store.go
index 568b448..8b9cae6 100644
--- a/src/hub/src/spreadspace.org/sfive/s5store.go
+++ b/src/hub/src/spreadspace.org/sfive/s5store.go
@@ -505,6 +505,18 @@ func (st Store) GetLastUpdateForUuid(uuid string) (updateId int, err error) {
return
}
+func (st Store) GetHubs() (res []string, err error) {
+ res = []string{st.hubUuid}
+ err = st.db.View(func(tx *bolt.Tx) error {
+ c := tx.Bucket([]byte(hubUuidsRevBn)).Cursor()
+ for k, v := c.First(); k != nil; k, v = c.Next() {
+ res = append(res, string(v))
+ }
+ return nil
+ })
+ return
+}
+
func (st Store) GetSource(id int) (res SourceId, err error) {
err = st.db.View(func(tx *bolt.Tx) error {
src, err := st.getSource(tx, id)
diff --git a/src/hub/src/spreadspace.org/sfive/s5store_test.go b/src/hub/src/spreadspace.org/sfive/s5store_test.go
index 67557d4..b9aa36c 100644
--- a/src/hub/src/spreadspace.org/sfive/s5store_test.go
+++ b/src/hub/src/spreadspace.org/sfive/s5store_test.go
@@ -253,6 +253,15 @@ func TestReadOnly(t *testing.T) {
//
}
+//
+// TODO: add tests for
+// * store.GetUpdatesAfter
+// * store.GetHubs
+// * store.GetSource(s)
+// * GetLastUpdateId
+// * GetLastUpdateForUuid
+//
+
func generateDataUpdateFull(n int) (data []DataUpdateFull) {
hostnames := []string{"streamer1", "streamer2"}
contents := []string{"av", "audio"}
diff --git a/src/hub/test-fwd b/src/hub/test-fwd
index 35dd324..371aa55 100755
--- a/src/hub/test-fwd
+++ b/src/hub/test-fwd
@@ -8,4 +8,4 @@ fi
TEST_D="./test"
TEST_DB="$TEST_D/$1.bolt"
-exec ./bin/sfive-hub -db "$TEST_DB" -start-pipe-server=false -start-pipegram-server=false -start-web-server=false -forward-url="http://localhost:8000"
+exec ./bin/sfive-hub -db "$TEST_DB" -read-only -start-pipe-server=false -start-pipegram-server=false -start-web-server=false -forward-url="http://localhost:8000"
diff --git a/src/hub/test-fwd-es b/src/hub/test-fwd-es
index 2d74db6..61bbcf7 100755
--- a/src/hub/test-fwd-es
+++ b/src/hub/test-fwd-es
@@ -8,4 +8,4 @@ fi
TEST_D="./test"
TEST_DB="$TEST_D/$1.bolt"
-exec ./bin/sfive-hub -db "$TEST_DB" -start-pipe-server=false -start-pipegram-server=false -start-web-server=false -forward-es-url="http://stream.elevate.at:9200/testing"
+exec ./bin/sfive-hub -db "$TEST_DB" -read-only -start-pipe-server=false -start-pipegram-server=false -start-web-server=false -forward-es-url="http://stream.elevate.at:9200/testing"
diff --git a/src/hub/test-fwd-piwik b/src/hub/test-fwd-piwik
index c7df4ae..8a2ae33 100755
--- a/src/hub/test-fwd-piwik
+++ b/src/hub/test-fwd-piwik
@@ -8,4 +8,4 @@ fi
TEST_D="./test"
TEST_DB="$TEST_D/$1.bolt"
-exec ./bin/sfive-hub -db "$TEST_DB" -start-pipe-server=false -start-pipegram-server=false -start-web-server=false -forward-piwik-url="http://localhost/piwik.php" -piwik-token "asdfjlkasjdflk" -piwik-site-id 4 -piwik-site-url "https://stream.elevate.at"
+exec ./bin/sfive-hub -db "$TEST_DB" -read-only -start-pipe-server=false -start-pipegram-server=false -start-web-server=false -forward-piwik-url="http://localhost/piwik.php" -piwik-token "asdfjlkasjdflk" -piwik-site-id 4 -piwik-site-url "https://stream.elevate.at"