You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2021/02/03 02:08:05 UTC

[servicecomb-service-center] branch master updated: [SCB-2094] add mongo index (#843)

This is an automated email from the ASF dual-hosted git repository.

tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 38e5176  [SCB-2094] add mongo index (#843)
38e5176 is described below

commit 38e5176b04d4a40757ff4fbe881b629b62954e51
Author: robotLJW <79...@qq.com>
AuthorDate: Wed Feb 3 10:07:53 2021 +0800

    [SCB-2094] add mongo index (#843)
---
 datasource/mongo/database.go |  4 ++--
 datasource/mongo/mongo.go    | 28 ++++++++++++++++++++++++++++
 go.mod                       |  4 ++--
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/datasource/mongo/database.go b/datasource/mongo/database.go
index aa1b973..f98f318 100644
--- a/datasource/mongo/database.go
+++ b/datasource/mongo/database.go
@@ -47,8 +47,8 @@ const (
 	ColumnServiceInfo         = "serviceinfo"
 	ColumnProperty            = "properties"
 	ColumnModTime             = "modtimestamp"
-	ColumnEnv                 = "environment"
-	ColumnAppID               = "appid"
+	ColumnEnv                 = "env"
+	ColumnAppID               = "app"
 	ColumnServiceName         = "servicename"
 	ColumnAlias               = "alias"
 	ColumnVersion             = "version"
diff --git a/datasource/mongo/mongo.go b/datasource/mongo/mongo.go
index 2f742a7..2248110 100644
--- a/datasource/mongo/mongo.go
+++ b/datasource/mongo/mongo.go
@@ -111,6 +111,7 @@ func (ds *DataSource) createIndexes() (err error) {
 			{Key: StringBuilder([]string{ColumnServiceInfo, ColumnEnv}), Value: bsonx.Int32(1)},
 			{Key: StringBuilder([]string{ColumnServiceInfo, ColumnVersion}), Value: bsonx.Int32(1)},
 			{Key: ColumnDomain, Value: bsonx.Int32(1)},
+			{Key: ColumnProject, Value: bsonx.Int32(1)},
 		},
 		Options: options.Index().SetUnique(true),
 	}})
@@ -129,6 +130,33 @@ func (ds *DataSource) createIndexes() (err error) {
 	if err != nil {
 		return
 	}
+	err = client.GetMongoClient().CreateIndexes(context.TODO(), CollectionSchema, []mongo.IndexModel{{
+		Keys: bsonx.Doc{
+			{Key: ColumnDomain, Value: bsonx.Int32(1)},
+			{Key: ColumnProject, Value: bsonx.Int32(1)},
+			{Key: ColumnServiceID, Value: bsonx.Int32(1)}},
+	}})
+	if err != nil {
+		return
+	}
+	err = client.GetMongoClient().CreateIndexes(context.TODO(), CollectionRule, []mongo.IndexModel{{
+		Keys: bsonx.Doc{
+			{Key: ColumnDomain, Value: bsonx.Int32(1)},
+			{Key: ColumnProject, Value: bsonx.Int32(1)},
+			{Key: ColumnServiceID, Value: bsonx.Int32(1)}},
+	}})
+	if err != nil {
+		return
+	}
+	err = client.GetMongoClient().CreateIndexes(context.TODO(), CollectionDep, []mongo.IndexModel{{
+		Keys: bsonx.Doc{
+			{Key: ColumnDomain, Value: bsonx.Int32(1)},
+			{Key: ColumnProject, Value: bsonx.Int32(1)},
+			{Key: ColumnServiceKey, Value: bsonx.Int32(1)}},
+	}})
+	if err != nil {
+		return
+	}
 	return
 }
 
diff --git a/go.mod b/go.mod
index 2ab6604..ccd2f53 100644
--- a/go.mod
+++ b/go.mod
@@ -17,8 +17,8 @@ require (
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/dustin/go-humanize v1.0.0 // indirect
 	github.com/ghodss/yaml v1.0.0
-	github.com/go-chassis/cari v0.0.2-0.20210111105320-0bb4211266b7
-	github.com/go-chassis/foundation v0.2.2-0.20201210043510-9f6d3de40234
+	github.com/go-chassis/cari v0.0.2-0.20210203013205-0083e3b092cf
+	github.com/go-chassis/foundation v0.2.2
 	github.com/go-chassis/go-archaius v1.3.6-0.20201130023516-387922b408d0
 	github.com/go-chassis/go-chassis/v2 v2.1.1-0.20201208095114-93feb76fd997
 	github.com/go-chassis/kie-client v0.0.0-20210122061843-eee856b0a9af