From 8f64eb1dcb0324d5aece543f8fa5d413432f9f11 Mon Sep 17 00:00:00 2001 From: Medzik Date: Wed, 8 Sep 2021 20:31:59 +0000 Subject: [PATCH] perf(database): change _id field to url BREAKING CHANGE: YOU MUST CHANGE `_id` TO `url` AND GENERATE ObjectID to `_id` IN MONGODB. --- database/mongo/types.go | 7 +++++-- ping/stopAfterPing.go | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/database/mongo/types.go b/database/mongo/types.go index 60a672e..a6c28cb 100644 --- a/database/mongo/types.go +++ b/database/mongo/types.go @@ -1,6 +1,9 @@ package mongo +import "go.mongodb.org/mongo-driver/bson/primitive" + type URL struct { - URL string `bson:"_id,omitempty" json:"url,omitempty"` - Cluster int `bson:"cluster,omitempty" json:"cluster,omitempty"` + ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"` + URL string `bson:"url,omitempty" json:"url,omitempty"` + Cluster int `bson:"cluster,omitempty" json:"cluster,omitempty"` } diff --git a/ping/stopAfterPing.go b/ping/stopAfterPing.go index 1317e8a..1e61679 100644 --- a/ping/stopAfterPing.go +++ b/ping/stopAfterPing.go @@ -40,5 +40,7 @@ func StopAfterPing() { break } + + time.Sleep(100 * time.Millisecond) // 0.1 second } }