diff --git a/backend/cache.go b/backend/cache.go index 584b988..3b8a793 100644 --- a/backend/cache.go +++ b/backend/cache.go @@ -12,7 +12,7 @@ func cache(retry int) { cacheURL = cacheURL[:0] results, err := mongo.GetAll() - if checkErr(err, "get keys from db") { + if checkErr(err, "get documents from db") { if retry == 5 { time.Sleep(500 * time.Millisecond) cache(retry + 1) diff --git a/database/mongo/connect.go b/database/mongo/connect.go index a887d47..ef088fa 100644 --- a/database/mongo/connect.go +++ b/database/mongo/connect.go @@ -20,7 +20,7 @@ func Connect(retry ...int8) { retry = append(retry, 0) } - if retry[0] == 2 { + if retry[0] == 5 { os.Exit(1) } diff --git a/database/mongo/getAll.go b/database/mongo/getAll.go index 1c99be1..9c7e384 100644 --- a/database/mongo/getAll.go +++ b/database/mongo/getAll.go @@ -13,8 +13,8 @@ func GetAll() ([]URL, error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - cursor, err := Coll.Find(ctx, json{ - "cluster": config.Toml.Cluster.ID, + cursor, err := Coll.Find(ctx, URL{ + Cluster: config.Toml.Cluster.ID, }) if err != nil { return nil, err diff --git a/database/mongo/types.go b/database/mongo/types.go index 7e6bac9..60a672e 100644 --- a/database/mongo/types.go +++ b/database/mongo/types.go @@ -1,8 +1,6 @@ package mongo type URL struct { - URL string `bson:"_id"` - Cluster int `bson:"cluster"` + URL string `bson:"_id,omitempty" json:"url,omitempty"` + Cluster int `bson:"cluster,omitempty" json:"cluster,omitempty"` } - -type json map[string]interface{} diff --git a/website/server.go b/website/server.go index a739c72..f7763d9 100644 --- a/website/server.go +++ b/website/server.go @@ -28,7 +28,7 @@ func Server() { api.ApplyRoutes(router) err := router.Run(":" + strconv.Itoa(config.Toml.HTTP.Port)) - if common.CheckErr(err, "gin start") { + if common.CheckErr(err, "gin server run") { os.Exit(1) } }