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 2021/11/25 14:16:19 UTC

[GitHub] [servicecomb-service-center] little-cui opened a new pull request #1169: Refactor schema service

little-cui opened a new pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169


   将契约的service独立出来
   
   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
    - [ ] Never comment source code, delete it.
    - [ ] UT should has "context, subject, expected result" result as test case name, when you call t.Run().
   ---
   


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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
little-cui commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767704882



##########
File path: server/resource/disco/schema_resource.go
##########
@@ -90,16 +94,15 @@ func (s *SchemaService) ModifySchema(w http.ResponseWriter, r *http.Request) {
 	query := r.URL.Query()
 	request.ServiceId = query.Get(":serviceId")
 	request.SchemaId = query.Get(":schemaId")
-	resp, err := core.ServiceAPI.ModifySchema(r.Context(), request)
-	if err != nil {
-		log.Error("can not update schema", err)
-		rest.WriteError(w, pb.ErrInternal, "can not update schema")
+	_, svcErr := discosvc.PutSchema(r.Context(), request)
+	if svcErr != nil {
+		rest.WriteServiceError(w, svcErr)

Review comment:
       代码内部已经统一打印
   ![image](https://user-images.githubusercontent.com/23383427/145810666-ca864004-d3e2-41ff-8193-33b3b54bdccf.png)
   




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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r765639767



##########
File path: server/resource/disco/schema_resource.go
##########
@@ -29,50 +29,54 @@ import (
 	"github.com/apache/servicecomb-service-center/pkg/rest"
 	"github.com/apache/servicecomb-service-center/pkg/util"
 	"github.com/apache/servicecomb-service-center/server/config"
-	"github.com/apache/servicecomb-service-center/server/core"
+	discosvc "github.com/apache/servicecomb-service-center/server/service/disco"
 	pb "github.com/go-chassis/cari/discovery"
 )
 
 var errModifySchemaDisabled = errors.New("schema modify is disabled")
 
-type SchemaService struct {
+type SchemaRouter struct {
 	//
 }
 
-func (s *SchemaService) URLPatterns() []rest.Route {
+func (s *SchemaRouter) URLPatterns() []rest.Route {

Review comment:
       应该是Resource

##########
File path: server/rest/controller/v4/v4.go
##########
@@ -28,7 +29,7 @@ func init() {
 func initRouter() {
 	roa.RegisterServant(&MainService{})
 	roa.RegisterServant(&MicroServiceService{})
-	roa.RegisterServant(&SchemaService{})
+	roa.RegisterServant(&disco.SchemaRouter{})

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.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767360822



##########
File path: server/resource/disco/schema_resource.go
##########
@@ -115,26 +118,29 @@ func (s *SchemaService) ModifySchemas(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 	request.ServiceId = serviceID
-	resp, err := core.ServiceAPI.ModifySchemas(r.Context(), request)
-	if err != nil {
-		log.Error("can not update schema", err)
-		rest.WriteError(w, pb.ErrInternal, "can not update schema")
+	_, svcErr := discosvc.PutSchemas(r.Context(), request)
+	if svcErr != nil {
+		rest.WriteServiceError(w, svcErr)

Review comment:
       错误日志

##########
File path: server/resource/disco/schema_resource.go
##########
@@ -115,26 +118,29 @@ func (s *SchemaService) ModifySchemas(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 	request.ServiceId = serviceID
-	resp, err := core.ServiceAPI.ModifySchemas(r.Context(), request)
-	if err != nil {
-		log.Error("can not update schema", err)
-		rest.WriteError(w, pb.ErrInternal, "can not update schema")
+	_, svcErr := discosvc.PutSchemas(r.Context(), request)
+	if svcErr != nil {
+		rest.WriteServiceError(w, svcErr)
 		return
 	}
-	rest.WriteResponse(w, r, resp.Response, nil)
+	rest.WriteResponse(w, r, nil, nil)
 }
 
-func (s *SchemaService) DeleteSchemas(w http.ResponseWriter, r *http.Request) {
+func (s *SchemaResource) DeleteSchema(w http.ResponseWriter, r *http.Request) {
 	query := r.URL.Query()
 	request := &pb.DeleteSchemaRequest{
 		ServiceId: query.Get(":serviceId"),
 		SchemaId:  query.Get(":schemaId"),
 	}
-	resp, _ := core.ServiceAPI.DeleteSchema(r.Context(), request)
-	rest.WriteResponse(w, r, resp.Response, nil)
+	_, err := discosvc.DeleteSchema(r.Context(), request)
+	if err != nil {
+		rest.WriteServiceError(w, err)

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.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang merged pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
tianxiaoliang merged pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169


   


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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767360353



##########
File path: server/rest/controller/v4/v4.go
##########
@@ -28,7 +29,7 @@ func init() {
 func initRouter() {
 	roa.RegisterServant(&MainService{})
 	roa.RegisterServant(&MicroServiceService{})
-	roa.RegisterServant(&SchemaService{})
+	roa.RegisterServant(&disco.SchemaRouter{})

Review comment:
       确实是先有版本,再有业务pkg更好




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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767360734



##########
File path: server/resource/disco/schema_resource.go
##########
@@ -90,16 +94,15 @@ func (s *SchemaService) ModifySchema(w http.ResponseWriter, r *http.Request) {
 	query := r.URL.Query()
 	request.ServiceId = query.Get(":serviceId")
 	request.SchemaId = query.Get(":schemaId")
-	resp, err := core.ServiceAPI.ModifySchema(r.Context(), request)
-	if err != nil {
-		log.Error("can not update schema", err)
-		rest.WriteError(w, pb.ErrInternal, "can not update schema")
+	_, svcErr := discosvc.PutSchema(r.Context(), request)
+	if svcErr != nil {
+		rest.WriteServiceError(w, svcErr)

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.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
little-cui commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767704882



##########
File path: server/resource/disco/schema_resource.go
##########
@@ -90,16 +94,15 @@ func (s *SchemaService) ModifySchema(w http.ResponseWriter, r *http.Request) {
 	query := r.URL.Query()
 	request.ServiceId = query.Get(":serviceId")
 	request.SchemaId = query.Get(":schemaId")
-	resp, err := core.ServiceAPI.ModifySchema(r.Context(), request)
-	if err != nil {
-		log.Error("can not update schema", err)
-		rest.WriteError(w, pb.ErrInternal, "can not update schema")
+	_, svcErr := discosvc.PutSchema(r.Context(), request)
+	if svcErr != nil {
+		rest.WriteServiceError(w, svcErr)

Review comment:
       代码内部已经统一打印
   ![image](https://user-images.githubusercontent.com/23383427/145810666-ca864004-d3e2-41ff-8193-33b3b54bdccf.png)
   




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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
little-cui commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767084981



##########
File path: server/rest/controller/v4/v4.go
##########
@@ -28,7 +29,7 @@ func init() {
 func initRouter() {
 	roa.RegisterServant(&MainService{})
 	roa.RegisterServant(&MicroServiceService{})
-	roa.RegisterServant(&SchemaService{})
+	roa.RegisterServant(&disco.SchemaRouter{})

Review comment:
       是否整改resource下加版本?
   ![image](https://user-images.githubusercontent.com/23383427/145662962-392cb995-300e-4874-b12d-44225756df89.png)
   




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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #1169: Refactor schema service

Posted by GitBox <gi...@apache.org>.
little-cui commented on a change in pull request #1169:
URL: https://github.com/apache/servicecomb-service-center/pull/1169#discussion_r767084981



##########
File path: server/rest/controller/v4/v4.go
##########
@@ -28,7 +29,7 @@ func init() {
 func initRouter() {
 	roa.RegisterServant(&MainService{})
 	roa.RegisterServant(&MicroServiceService{})
-	roa.RegisterServant(&SchemaService{})
+	roa.RegisterServant(&disco.SchemaRouter{})

Review comment:
       是否整改resource下加版本?
   ![image](https://user-images.githubusercontent.com/23383427/145662962-392cb995-300e-4874-b12d-44225756df89.png)
   




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

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org