Merge branch 'develop' of ssh://github.com/alice-lg/alice-lg into develop

This commit is contained in:
Annika Hannig 2022-03-14 09:02:46 +01:00
commit bd2d0b61ee
8 changed files with 20 additions and 3 deletions

View File

@ -120,7 +120,7 @@ func main() {
log.Println("Using configuration:", cfg.File)
// Start stores
if cfg.Server.EnablePrefixLookup == true {
if cfg.Server.EnablePrefixLookup {
go neighborsStore.Start()
go routesStore.Start()
}

View File

@ -30,6 +30,9 @@ func (s *Server) apiNeighborsList(
// from the summary.
if s.neighborsStore.IsInitialized(rsID) {
status, err := s.neighborsStore.GetStatus(rsID)
if err != nil {
return nil, err
}
neighbors, err := s.neighborsStore.GetNeighborsAt(ctx, rsID)
if err != nil {
return nil, err

View File

@ -97,7 +97,7 @@ func Test_RoutesParsing(t *testing.T) {
config := Config{Timezone: "UTC"} // Or ""
bird, _ := parseTestResponse(APIResponseRoutes)
routes, err := parseRoutes(bird, config)
routes, err := parseRoutes(bird, config, true)
if err != nil {
t.Error(err)
}

View File

@ -0,0 +1,6 @@
// Package postgres is an implementation of a routes and neighbors
// store using the postgres database.
//
// Routes and neighbors are stored as jsonb information
// with indexes for query performance.
package postgres

View File

@ -113,6 +113,7 @@ func TestGetNeighbors(t *testing.T) {
if err == nil {
t.Error("Unknown source should have yielded zero results")
}
t.Log(neighbors)
}

8
pkg/store/package.go Normal file
View File

@ -0,0 +1,8 @@
// Package store provides an interface for keeping
// routes and neighbor information without querying
// a route server. The refresh happens in a configurable
// interval.
//
// There a currently two implementations: A postgres and
// and in-memory backend.
package store

View File

@ -318,5 +318,4 @@ func (s *SourcesStore) RefreshError(
status.LastRefresh = time.Now().UTC()
status.LastRefreshDuration = time.Since(status.lastRefreshStart)
status.LastError = sourceErr
return
}