Skip to content

Commit

Permalink
apache#79 消息轨迹推送跟踪
Browse files Browse the repository at this point in the history
  • Loading branch information
develpoerX committed Dec 28, 2020
1 parent ade7875 commit 31265cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions deployments/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ db.kv_revision.createIndex({"delete_time": 1}, {expireAfterSeconds: 7 * 24 * 360
db.label.createIndex({"id": 1}, {unique: true});
db.label.createIndex({format: 1, domain: 1, project: 1}, {unique: true});
db.polling_detail.createIndex({timestamp: 1}, {expireAfterSeconds: 7 * 24 * 3600});
db.polling_detail.createIndex({revision: 1, session_id: 1, domain: 1}, {unique: true});
db.counter.createIndex({name: 1, domain: 1}, {unique: true});
db.view.createIndex({"id": 1}, {unique: true});
db.view.createIndex({display: 1, domain: 1, project: 1}, {unique: true});
Expand Down
5 changes: 5 additions & 0 deletions server/service/mongo/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func ensureKVLongPolling(session *mgo.Session) {
ExpireAfter: 7 * 24 * time.Hour,
})
wrapError(err)
err = c.EnsureIndex(mgo.Index{
Key: []string{"revision", "domain", "session_id"},
Unique: true,
})
wrapError(err)
}

func ensureView(session *mgo.Session) {
Expand Down
2 changes: 1 addition & 1 deletion server/service/mongo/track/polling_detail_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
//If revision and session_id is exist: update else:insert
func CreateOrUpdate(ctx context.Context, detail *model.PollingDetail) (*model.PollingDetail, error) {
collection := session.GetDB().Collection(session.CollectionPollingDetail)
queryFilter := bson.M{"revision": detail.Domain, "session_id": detail.SessionID}
queryFilter := bson.M{"revision": detail.Revision, "domain": detail.Domain, "session_id": detail.SessionID}
res := collection.FindOne(ctx, queryFilter)
if res.Err() != nil {
if res.Err() == mongo.ErrNoDocuments {
Expand Down

0 comments on commit 31265cb

Please sign in to comment.