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/02/11 02:14:50 UTC

[GitHub] [servicecomb-kie] GuoYL123 opened a new pull request #90: record polling history

GuoYL123 opened a new pull request #90: record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90
 
 
   

----------------------------------------------------------------
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] GuoYL123 commented on a change in pull request #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378062463
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -189,6 +200,37 @@ func returnData(rctx *restful.Context, domain interface{}, project string, label
 	}
 }
 
+//RecordPollingDetail to record data after get or list
+func RecordPollingDetail(context *restful.Context, revStr, wait, domain, project string, labels map[string]string, limit, offset int64, insId string) {
+	Wg.Add(1)
+	data := &model.PollingDetail{}
+	data.ID = insId + domain
 
 Review comment:
   done

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378235367
 
 

 ##########
 File path: server/resource/v1/common.go
 ##########
 @@ -226,20 +236,26 @@ func queryAndResponse(rctx *restful.Context,
 	kv, err := service.KVService.List(rctx.Ctx, domain.(string), project, opts...)
 	if err != nil {
 		if err == service.ErrKeyNotExists {
-			WriteErrResponse(rctx, http.StatusNotFound, err.Error(), common.ContentTypeText)
+			WriteErrResponseWithRecord(rctx, http.StatusNotFound, err.Error(), common.ContentTypeText, record)
 			return
 		}
-		WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText)
+		WriteErrResponseWithRecord(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText, record)
 		return
 	}
 	rev, err := service.RevisionService.GetRevision(rctx.Ctx, domain.(string))
 	if err != nil {
-		WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText)
+		WriteErrResponseWithRecord(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText, record)
 		return
 	}
 	rctx.ReadResponseWriter().Header().Set(common.HeaderRevision, strconv.FormatInt(rev, 10))
 	err = writeResponse(rctx, kv)
 	if err != nil {
 		openlogging.Error(err.Error())
 	}
+	respData, _ := json.Marshal(kv)
+	respHeader, _ := json.Marshal(rctx.Resp.Header())
 
 Review comment:
   不要序列化直接存map

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r377982142
 
 

 ##########
 File path: server/service/mongo/record/polling_detail_dao.go
 ##########
 @@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package record
+
+import (
+	"context"
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/apache/servicecomb-kie/server/service/mongo/session"
+)
+
+//CreateRecord to create a record
+func CreateRecord(ctx context.Context, detail *model.PollingDetail) (*model.PollingDetail, error) {
 
 Review comment:
   polling 应当有update和create2个方法

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378237474
 
 

 ##########
 File path: pkg/model/kv.go
 ##########
 @@ -54,3 +54,17 @@ type ViewResponse struct {
 	Total int        `json:"total,omitempty"`
 	Data  []*ViewDoc `json:"data,omitempty"`
 }
+
+//PollingDetail record operation history
+type PollingDetail struct {
+	ID             string                 `json:"id,omitempty" yaml:"id,omitempty"`
+	SessionID      string                 `json:"session_id,omitempty" yaml:"session_id,omitempty"`
+	Domain         string                 `json:"domain,omitempty" yaml:"domain,omitempty"`
+	PollingData    map[string]interface{} `json:"polling_data,omitempty" yaml:"polling_data,omitempty"`
+	IP             string                 `json:"ip,omitempty" yaml:"ip,omitempty"`
+	UserAgent      string                 `json:"user_agent,omitempty" yaml:"user_agent,omitempty"`
+	URLPath        string                 `json:"url_path,omitempty" yaml:"url_path,omitempty"`
+	ResponseBody   string                 `json:"response_body,omitempty" yaml:"response_body,omitempty"`
+	ResponseHeader string                 `json:"response_header,omitempty" yaml:"response_header,omitempty"`
 
 Review comment:
   ResponseHeader 用map[string][]string

----------------------------------------------------------------
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] GuoYL123 commented on a change in pull request #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378096349
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -130,9 +137,11 @@ func (r *KVResource) List(rctx *restful.Context) {
 	returnData(rctx, domain, project, labels, limit, offset)
 }
 
+//
 func returnData(rctx *restful.Context, domain interface{}, project string, labels map[string]string, limit, offset int64) {
 	revStr := rctx.ReadQueryParameter(common.QueryParamRev)
 	wait := rctx.ReadQueryParameter(common.QueryParamWait)
+	go RecordPollingDetail(rctx, revStr, wait, domain.(string), project, labels, limit, offset)
 
 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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378239595
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -138,21 +141,24 @@ func (r *KVResource) List(rctx *restful.Context) {
 		WriteErrResponse(rctx, http.StatusBadRequest, err.Error(), common.ContentTypeText)
 		return
 	}
+	insID := rctx.ReadHeader("insId")
 
 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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378238894
 
 

 ##########
 File path: server/service/mongo/record/polling_detail_dao.go
 ##########
 @@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package record
+
+import (
+	"context"
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/apache/servicecomb-kie/server/service/mongo/session"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/mongo"
+)
+
+//CreateOrUpdateRecord create a record or update exist record
+func CreateOrUpdateRecord(ctx context.Context, detail *model.PollingDetail) (*model.PollingDetail, error) {
 
 Review comment:
   Record这个尾椎多余,要时刻考虑clean code,这里有上下文了

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r377981474
 
 

 ##########
 File path: server/resource/v1/common.go
 ##########
 @@ -232,3 +233,20 @@ func queryAndResponse(rctx *restful.Context,
 		openlogging.Error(err.Error())
 	}
 }
+
+//ClientIP try to get ip from http header
+func ClientIP(r *http.Request) string {
 
 Review comment:
   这个放到pkg包下,属于通用lib

----------------------------------------------------------------
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] GuoYL123 closed pull request #90: record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 closed pull request #90: record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90
 
 
   

----------------------------------------------------------------
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] GuoYL123 opened a new pull request #90: record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 opened a new pull request #90: record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90
 
 
   

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378237956
 
 

 ##########
 File path: server/service/service.go
 ##########
 @@ -64,6 +65,12 @@ type Label interface {
 	CreateOrUpdate(ctx context.Context, label *model.LabelDoc) (*model.LabelDoc, error)
 }
 
+//Record manages record data
+type Record interface {
+	RecordSuccess(ctx context.Context, detail *model.PollingDetail, respStatus int, respData, respHeader string) (*model.PollingDetail, error)
 
 Review comment:
   没必要搞2个func 合成一个,非必填参数用functional 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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378055513
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -189,6 +200,37 @@ func returnData(rctx *restful.Context, domain interface{}, project string, label
 	}
 }
 
+//RecordPollingDetail to record data after get or list
+func RecordPollingDetail(context *restful.Context, revStr, wait, domain, project string, labels map[string]string, limit, offset int64, insId string) {
+	Wg.Add(1)
+	data := &model.PollingDetail{}
+	data.ID = insId + domain
 
 Review comment:
   insId + domain只是数据库里的unique id, 不用拼在一起,id就是服务端生成的uuid,增加个字段session id来代替这个insId

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378235193
 
 

 ##########
 File path: server/resource/v1/common.go
 ##########
 @@ -226,20 +236,26 @@ func queryAndResponse(rctx *restful.Context,
 	kv, err := service.KVService.List(rctx.Ctx, domain.(string), project, opts...)
 	if err != nil {
 		if err == service.ErrKeyNotExists {
-			WriteErrResponse(rctx, http.StatusNotFound, err.Error(), common.ContentTypeText)
+			WriteErrResponseWithRecord(rctx, http.StatusNotFound, err.Error(), common.ContentTypeText, record)
 			return
 		}
-		WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText)
+		WriteErrResponseWithRecord(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText, record)
 		return
 	}
 	rev, err := service.RevisionService.GetRevision(rctx.Ctx, domain.(string))
 	if err != nil {
-		WriteErrResponse(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText)
+		WriteErrResponseWithRecord(rctx, http.StatusInternalServerError, err.Error(), common.ContentTypeText, record)
 		return
 	}
 	rctx.ReadResponseWriter().Header().Set(common.HeaderRevision, strconv.FormatInt(rev, 10))
 	err = writeResponse(rctx, kv)
 	if err != nil {
 		openlogging.Error(err.Error())
 	}
+	respData, _ := json.Marshal(kv)
 
 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] GuoYL123 commented on a change in pull request #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378060330
 
 

 ##########
 File path: server/resource/v1/common.go
 ##########
 @@ -232,3 +233,20 @@ func queryAndResponse(rctx *restful.Context,
 		openlogging.Error(err.Error())
 	}
 }
+
+//ClientIP try to get ip from http header
+func ClientIP(r *http.Request) string {
 
 Review comment:
   done

----------------------------------------------------------------
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] GuoYL123 commented on a change in pull request #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378060521
 
 

 ##########
 File path: server/service/mongo/record/polling_detail_dao.go
 ##########
 @@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package record
+
+import (
+	"context"
+	"github.com/apache/servicecomb-kie/pkg/model"
+	"github.com/apache/servicecomb-kie/server/service/mongo/session"
+)
+
+//CreateRecord to create a record
+func CreateRecord(ctx context.Context, detail *model.PollingDetail) (*model.PollingDetail, error) {
 
 Review comment:
   改成了 CreateOrUpdateRecord

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378237822
 
 

 ##########
 File path: server/service/service.go
 ##########
 @@ -64,6 +65,12 @@ type Label interface {
 	CreateOrUpdate(ctx context.Context, label *model.LabelDoc) (*model.LabelDoc, error)
 }
 
+//Record manages record data
+type Record interface {
 
 Review comment:
   Record 就叫PollingRecorder

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378235796
 
 

 ##########
 File path: deployments/db.js
 ##########
 @@ -96,11 +96,53 @@ db.createCollection( "view", {
             }
         } }
 } );
+
+db.createCollection( "polling_detail", {
+    validator: { $jsonSchema: {
+            bsonType: "object",
+            required: [ "id","polling_date","ip","user_agent","url_path","response_body","response_header" ],
+            properties: {
+                id: {
+                    bsonType: "string",
+                },
+                session_id: {
+                    bsonType: "string",
+                },
+                domain: {
+                    bsonType: "string",
+                },
+                polling_date: {
+                    bsonType: "string"
+                },
+                ip: {
+                    bsonType: "string"
+                },
+                user_agent: {
+                    bsonType: "string"
+                },
+                url_path: {
+                    bsonType: "string"
+                },
+                response_body: {
+                    bsonType: "string"
+                },
+                response_header: {
+                    bsonType: "string"
 
 Review comment:
   不应该是个string应该是个bson object

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378235749
 
 

 ##########
 File path: deployments/db.js
 ##########
 @@ -96,11 +96,53 @@ db.createCollection( "view", {
             }
         } }
 } );
+
+db.createCollection( "polling_detail", {
+    validator: { $jsonSchema: {
+            bsonType: "object",
+            required: [ "id","polling_date","ip","user_agent","url_path","response_body","response_header" ],
+            properties: {
+                id: {
+                    bsonType: "string",
+                },
+                session_id: {
+                    bsonType: "string",
+                },
+                domain: {
+                    bsonType: "string",
+                },
+                polling_date: {
+                    bsonType: "string"
+                },
+                ip: {
+                    bsonType: "string"
+                },
+                user_agent: {
+                    bsonType: "string"
+                },
+                url_path: {
+                    bsonType: "string"
+                },
+                response_body: {
+                    bsonType: "string"
 
 Review comment:
   不应该是个string应该是个bson object

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378239415
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -191,21 +198,47 @@ func returnData(rctx *restful.Context, domain interface{}, project string, label
 				DomainID:  domain.(string),
 			})
 			if err != nil {
-				WriteErrResponse(rctx, http.StatusBadRequest, err.Error(), common.ContentTypeText)
+				WriteErrResponseWithRecord(rctx, http.StatusBadRequest, err.Error(), common.ContentTypeText, recordData)
 				return
 			}
 			if changed {
-				queryAndResponse(rctx, domain, project, "", labels, limit, offset, status)
+				queryAndResponse(rctx, domain, project, "", labels, limit, offset, status, recordData)
 				return
 			}
 			rctx.WriteHeader(http.StatusNotModified)
-			return
+			_, recordErr = service.RecordService.RecordSuccess(rctx.Ctx, recordData, http.StatusNotModified, "", "")
 
 Review comment:
   太多地方需要考虑调用,不如用defer+一个func,虽然损失性能,但是优雅易维护

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r377981851
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -130,9 +137,11 @@ func (r *KVResource) List(rctx *restful.Context) {
 	returnData(rctx, domain, project, labels, limit, offset)
 }
 
+//
 func returnData(rctx *restful.Context, domain interface{}, project string, labels map[string]string, limit, offset int64) {
 	revStr := rctx.ReadQueryParameter(common.QueryParamRev)
 	wait := rctx.ReadQueryParameter(common.QueryParamWait)
+	go RecordPollingDetail(rctx, revStr, wait, domain.(string), project, labels, limit, offset)
 
 Review comment:
   不能够这么搞,应该在handler里根据url和method判断是polling动作就进分支记录polling信息

----------------------------------------------------------------
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] GuoYL123 closed pull request #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
GuoYL123 closed pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90
 
 
   

----------------------------------------------------------------
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 #90: #79 record polling history

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #90: #79 record polling history
URL: https://github.com/apache/servicecomb-kie/pull/90#discussion_r378237274
 
 

 ##########
 File path: pkg/model/kv.go
 ##########
 @@ -54,3 +54,17 @@ type ViewResponse struct {
 	Total int        `json:"total,omitempty"`
 	Data  []*ViewDoc `json:"data,omitempty"`
 }
+
+//PollingDetail record operation history
+type PollingDetail struct {
+	ID             string                 `json:"id,omitempty" yaml:"id,omitempty"`
+	SessionID      string                 `json:"session_id,omitempty" yaml:"session_id,omitempty"`
+	Domain         string                 `json:"domain,omitempty" yaml:"domain,omitempty"`
+	PollingData    map[string]interface{} `json:"polling_data,omitempty" yaml:"polling_data,omitempty"`
+	IP             string                 `json:"ip,omitempty" yaml:"ip,omitempty"`
+	UserAgent      string                 `json:"user_agent,omitempty" yaml:"user_agent,omitempty"`
+	URLPath        string                 `json:"url_path,omitempty" yaml:"url_path,omitempty"`
+	ResponseBody   string                 `json:"response_body,omitempty" yaml:"response_body,omitempty"`
 
 Review comment:
   ResponseBody   用 struct

----------------------------------------------------------------
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