moved http api
This commit is contained in:
parent
977e4db816
commit
39e2605707
@ -30,7 +30,7 @@ type RoutesStoreStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log writes stats to the log
|
// Log writes stats to the log
|
||||||
func (stats RoutesStoreStats) Log() {
|
func (stats *RoutesStoreStats) Log() {
|
||||||
log.Println("Routes store:")
|
log.Println("Routes store:")
|
||||||
log.Println(" Routes Imported:",
|
log.Println(" Routes Imported:",
|
||||||
stats.TotalRoutes.Imported,
|
stats.TotalRoutes.Imported,
|
||||||
@ -65,7 +65,7 @@ type NeighborsStoreStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log prints the stats
|
// Log prints the stats
|
||||||
func (stats NeighborsStoreStats) Log() {
|
func (stats *NeighborsStoreStats) Log() {
|
||||||
log.Println("Neighbors store:")
|
log.Println("Neighbors store:")
|
||||||
|
|
||||||
log.Println(" Neighbors:",
|
log.Println(" Neighbors:",
|
||||||
|
7
pkg/backend/.gitignore
vendored
7
pkg/backend/.gitignore
vendored
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
# Ignore static build in repo
|
|
||||||
rice-box.go
|
|
||||||
|
|
||||||
# Ignore builds
|
|
||||||
alice-lg-*
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
package backend
|
|
||||||
|
|
||||||
// Globals
|
|
||||||
var (
|
|
||||||
AliceConfig *Config
|
|
||||||
AliceRoutesStore *RoutesStore
|
|
||||||
AliceNeighborsStore *NeighborsStore
|
|
||||||
)
|
|
||||||
|
|
||||||
// InitConfig loads the configuration into the global
|
|
||||||
// AliceConfig
|
|
||||||
func InitConfig(filename string) error {
|
|
||||||
var err error
|
|
||||||
AliceConfig, err = loadConfig(filename)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitStores initializes the routes and neighbors cache
|
|
||||||
func InitStores() {
|
|
||||||
AliceNeighborsStore = NewNeighborsStore(AliceConfig)
|
|
||||||
AliceRoutesStore = NewRoutesStore(AliceConfig)
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
// Improve error handling
|
// Improve error handling
|
||||||
// Create api.ErrorResponses based on errors returned from server.
|
// Create api.ErrorResponses based on errors returned from server.
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Paginate api routes responses
|
Paginate api routes responses
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The theme provides a method for adding customized CSS
|
The theme provides a method for adding customized CSS
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
@ -1,4 +1,4 @@
|
|||||||
package backend
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
@ -299,7 +299,7 @@ func (s *NeighborsStore) FilterNeighbors(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stats exports some statistics for monitoring.
|
// Stats exports some statistics for monitoring.
|
||||||
func (s *NeighborsStore) Stats() NeighborsStoreStats {
|
func (s *NeighborsStore) Stats() *NeighborsStoreStats {
|
||||||
totalNeighbors := 0
|
totalNeighbors := 0
|
||||||
rsStats := []RouteServerNeighborsStats{}
|
rsStats := []RouteServerNeighborsStats{}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ func (s *NeighborsStore) Stats() NeighborsStoreStats {
|
|||||||
}
|
}
|
||||||
s.RUnlock()
|
s.RUnlock()
|
||||||
|
|
||||||
storeStats := NeighborsStoreStats{
|
storeStats := &NeighborsStoreStats{
|
||||||
TotalNeighbors: totalNeighbors,
|
TotalNeighbors: totalNeighbors,
|
||||||
RouteServers: rsStats,
|
RouteServers: rsStats,
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func (rs *RoutesStore) update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stats calculates some store insights
|
// Stats calculates some store insights
|
||||||
func (rs *RoutesStore) Stats() RoutesStoreStats {
|
func (rs *RoutesStore) Stats() *api.RoutesStoreStats {
|
||||||
totalImported := 0
|
totalImported := 0
|
||||||
totalFiltered := 0
|
totalFiltered := 0
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ func (rs *RoutesStore) Stats() RoutesStoreStats {
|
|||||||
rs.RUnlock()
|
rs.RUnlock()
|
||||||
|
|
||||||
// Make stats
|
// Make stats
|
||||||
storeStats := RoutesStoreStats{
|
storeStats := &RoutesStoreStats{
|
||||||
TotalRoutes: RoutesStats{
|
TotalRoutes: RoutesStats{
|
||||||
Imported: totalImported,
|
Imported: totalImported,
|
||||||
Filtered: totalFiltered,
|
Filtered: totalFiltered,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user