mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
fix: add omitempty to types fields, change error message
This commit is contained in:
parent
35298bacfc
commit
0ba1c8a2c0
5 changed files with 7 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -20,7 +20,7 @@ func Connect(retry ...int8) {
|
|||
retry = append(retry, 0)
|
||||
}
|
||||
|
||||
if retry[0] == 2 {
|
||||
if retry[0] == 5 {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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{}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue