You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/01/15 09:03:38 UTC

[GitHub] [servicecomb-kie] AngLi2 opened a new pull request #71: SCB-1723 support pagination in kie apis

AngLi2 opened a new pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r367818524
 
 

 ##########
 File path: server/service/service.go
 ##########
 @@ -41,15 +41,15 @@ var (
 type KV interface {
 	//below 3 methods is usually for admin console
 	CreateOrUpdate(ctx context.Context, kv *model.KVDoc) (*model.KVDoc, error)
-	List(ctx context.Context, domain, project string, limit, offset int, options ...FindOption) (*model.KVResponse, error)
+	List(ctx context.Context, domain, project string, limit, offset int64, options ...FindOption) (*model.KVResponse, error)
 	Delete(ctx context.Context, kvID string, domain, project string) error
 	//FindKV is usually for service to pull configs
-	FindKV(ctx context.Context, domain, project string, options ...FindOption) ([]*model.KVResponse, error)
+	FindKV(ctx context.Context, domain, project string, limit, offset int64, options ...FindOption) ([]*model.KVResponse, error)
 
 Review comment:
   param还是有点长了,把limit 和offset放到functonal options里面把

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r367816714
 
 

 ##########
 File path: examples/dev/db.js
 ##########
 @@ -47,4 +47,5 @@ db.createCollection( "kv", {
         } }
 } );
 db.kv.createIndex({"id": 1}, { unique: true } );
-db.kv.createIndex({key: 1, label_id: 1,domain:1,project:1},{ unique: true });
\ No newline at end of file
+db.kv.createIndex({key: 1, label_id: 1,domain:1,project:1},{ unique: true });
+db.setProfilingLevel(1, {slowms: 80, sampleRate: 1} );
 
 Review comment:
   这行代码的作用是?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r368259674
 
 

 ##########
 File path: server/resource/v1/history_resource.go
 ##########
 @@ -37,13 +37,23 @@ type HistoryResource struct {
 func (r *HistoryResource) GetRevisions(context *restful.Context) {
 	var err error
 	labelID := context.ReadPathParameter("key_id")
 
 Review comment:
   labelID 这个变量我写错了,帮我改下吧,实际是根据key id查询历史

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] AngLi2 commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
AngLi2 commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r367819938
 
 

 ##########
 File path: examples/dev/db.js
 ##########
 @@ -47,4 +47,5 @@ db.createCollection( "kv", {
         } }
 } );
 db.kv.createIndex({"id": 1}, { unique: true } );
-db.kv.createIndex({key: 1, label_id: 1,domain:1,project:1},{ unique: true });
\ No newline at end of file
+db.kv.createIndex({key: 1, label_id: 1,domain:1,project:1},{ unique: true });
+db.setProfilingLevel(1, {slowms: 80, sampleRate: 1} );
 
 Review comment:
   mongoDB 的 slow query 日志,设置为 1 是只收集慢查询日志,slowms 是定义时间大于 80ms 的 query 为 slow query,sampleRate 是收集百分比,设置为 1 就是所有慢查询都收集到日志。可以后期分析 mongoDB 性能瓶颈优化慢查询

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r367873712
 
 

 ##########
 File path: examples/dev/db.js
 ##########
 @@ -47,4 +47,5 @@ db.createCollection( "kv", {
         } }
 } );
 db.kv.createIndex({"id": 1}, { unique: true } );
-db.kv.createIndex({key: 1, label_id: 1,domain:1,project:1},{ unique: true });
\ No newline at end of file
+db.kv.createIndex({key: 1, label_id: 1,domain:1,project:1},{ unique: true });
+db.setProfilingLevel(1, {slowms: 80, sampleRate: 1} );
 
 Review comment:
   赞

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang merged pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r367818020
 
 

 ##########
 File path: server/service/mongo/history/dao.go
 ##########
 @@ -27,11 +27,11 @@ import (
 	"go.mongodb.org/mongo-driver/mongo/options"
 )
 
-func getHistoryByKeyID(ctx context.Context, filter bson.M) ([]*model.KVDoc, error) {
+func getHistoryByKeyID(ctx context.Context, filter bson.M, limit, offset int64) ([]*model.KVDoc, error) {
 	collection := session.GetDB().Collection(session.CollectionKVRevision)
 	cur, err := collection.Find(ctx, filter, options.Find().SetSort(map[string]interface{}{
 		"revision": -1,
-	}))
+	}).SetSkip(offset*limit).SetLimit(limit))
 
 Review comment:
   offset就是偏移量,是由前台算出来的,不需要再乘以限制数

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [servicecomb-kie] tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #71: SCB-1723 support pagination in kie apis
URL: https://github.com/apache/servicecomb-kie/pull/71#discussion_r367818202
 
 

 ##########
 File path: server/service/mongo/kv/kv_service.go
 ##########
 @@ -110,7 +110,7 @@ func (s *Service) Exist(ctx context.Context, domain, key string, project string,
 		}
 		return kvs[0], nil
 	}
-	kvs, err := s.FindKV(ctx, domain, project,
+	kvs, err := s.FindKV(ctx, domain, project, 2, 0,
 
 Review comment:
   魔鬼数字

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services