You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/10 04:17:58 UTC
[GitHub] [dubbo-go] Leospard opened a new pull request, #1963: [WIP] Enhance ServiceDefinition in MetadataService
Leospard opened a new pull request, #1963:
URL: https://github.com/apache/dubbo-go/pull/1963
<!-- Thanks for sending a pull request!
Read https://github.com/apache/dubbo-go/blob/master/CONTRIBUTING.md before commit pull request.
-->
**What this PR does**:
Enhance ServiceDefinition in MetadataService
**Which issue(s) this PR fixes**:
Fixes #
**You should pay attention to items below to ensure your pr passes our ci test**
We do not merge pr with ci tests failed
- [ ] All ut passed (run 'go test ./...' in project root)
- [ ] After go-fmt ed , run 'go fmt project' using goland.
- [ ] Golangci-lint passed, run 'sudo golangci-lint run' in project root.
- [ ] After import formatted, (using [imports-formatter](https://github.com/dubbogo/tools#5-how-to-get-imports-formatter) to run 'imports-formatter .' in project root, to format your import blocks, mentioned in [CONTRIBUTING.md](https://github.com/apache/dubbo-go/blob/master/CONTRIBUTING.md) above)
- [ ] Your new-created file needs to have [apache license](https://raw.githubusercontent.com/dubbogo/resources/master/tools/license/license.txt) at the top, like other existed file does.
- [ ] All integration test passed. You can run integration test locally (with docker env). Clone our [dubbo-go-samples](https://github.com/apache/dubbo-go-samples) project and replace the go.mod to your dubbo-go, and run 'sudo sh start_integration_test.sh' at root of samples project root. (M1 Slice is not Support)
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks merged pull request #1963: [Ftr] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
AlexStocks merged PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks commented on a diff in pull request #1963: [Ftr] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963#discussion_r937343210
##########
metadata/definition/definition.go:
##########
@@ -121,6 +122,55 @@ func BuildServiceDefinition(service common.Service, url *common.URL) *ServiceDef
return sd
}
+// BuildFullDefinition can build service definition with full url parameters
+func BuildFullDefinition(service common.Service, url *common.URL) *FullServiceDefinition {
+ fsd := &FullServiceDefinition{}
+ sd := BuildServiceDefinition(service, url)
+ fsd.ServiceDefinition = *sd
+ fsd.Parameters = make(map[string]string)
+ for k, v := range url.GetParams() {
+ fsd.Parameters[k] = strings.Join(v, ",")
+ }
+ return fsd
+}
+
+// ToBytes convert ServiceDefinition to json string
+func (def *FullServiceDefinition) ToBytes() ([]byte, error) {
+ return json.Marshal(def)
+}
+
+// String will iterate all methods and parameters and convert them to json string
+func (def *FullServiceDefinition) String() string {
+ var methodStr strings.Builder
+ for _, m := range def.Methods {
+ var paramType strings.Builder
+ for _, p := range m.ParameterTypes {
+ paramType.WriteString(fmt.Sprintf("{type:%v}", p))
+ }
+ var param strings.Builder
+ for _, d := range m.Parameters {
+ param.WriteString(fmt.Sprintf("{id:%v,type:%v,builderName:%v}", d.ID, d.Type, d.TypeBuilderName))
+ }
+ methodStr.WriteString(fmt.Sprintf("{name:%v,parameterTypes:[%v],returnType:%v,params:[%v] }", m.Name, paramType.String(), m.ReturnType, param.String()))
+ }
+ var types strings.Builder
+ for _, d := range def.Types {
+ types.WriteString(fmt.Sprintf("{id:%v,type:%v,builderName:%v}", d.ID, d.Type, d.TypeBuilderName))
+ }
+
+ sortSlice := make([]string, 0)
+ var parameters strings.Builder
+ for k := range def.Parameters {
+ sortSlice = append(sortSlice, k)
+ }
+ sort.Slice(sortSlice, func(i, j int) bool { return sortSlice[i] < sortSlice[j] })
+ for _, k := range sortSlice {
+ parameters.WriteString(fmt.Sprintf("%v:%v,", k, def.Parameters[k]))
+ }
+
+ return fmt.Sprintf("{parameters:{%v}, canonicalName:%v, codeSource:%v, methods:[%v], types:[%v]}", strings.TrimRight(parameters.String(), ","), def.CanonicalName, def.CodeSource, methodStr.String(), types.String())
Review Comment:
so long, pls split it into two lines.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks commented on pull request #1963: [WIP] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
AlexStocks commented on PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963#issuecomment-1186312908
pls fix the ci failure.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] codecov-commenter commented on pull request #1963: [WIP] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963#issuecomment-1188594534
# [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1963?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#1963](https://codecov.io/gh/apache/dubbo-go/pull/1963?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2d122f5) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/026711bc0921596c819daa81500dbcc20f73af95?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (026711b) will **decrease** coverage by `0.51%`.
> The diff coverage is `51.56%`.
```diff
@@ Coverage Diff @@
## 3.0 #1963 +/- ##
==========================================
- Coverage 44.96% 44.44% -0.52%
==========================================
Files 287 283 -4
Lines 17135 17072 -63
==========================================
- Hits 7704 7588 -116
- Misses 8618 8676 +58
+ Partials 813 808 -5
```
| [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1963?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [cluster/cluster/base/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2Jhc2UvY2x1c3Rlcl9pbnZva2VyLmdv) | `37.77% <ø> (+13.33%)` | :arrow_up: |
| [cluster/cluster/broadcast/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2Jyb2FkY2FzdC9jbHVzdGVyX2ludm9rZXIuZ28=) | `80.00% <ø> (ø)` | |
| [cluster/cluster/failback/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZhaWxiYWNrL2NsdXN0ZXJfaW52b2tlci5nbw==) | `75.82% <ø> (ø)` | |
| [cluster/cluster/failover/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZhaWxvdmVyL2NsdXN0ZXJfaW52b2tlci5nbw==) | `66.66% <ø> (ø)` | |
| [cluster/cluster/failsafe/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZhaWxzYWZlL2NsdXN0ZXJfaW52b2tlci5nbw==) | `81.81% <ø> (ø)` | |
| [cluster/cluster/forking/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2ZvcmtpbmcvY2x1c3Rlcl9pbnZva2VyLmdv) | `58.33% <ø> (ø)` | |
| [cluster/loadbalance/p2c/loadbalance.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9wMmMvbG9hZGJhbGFuY2UuZ28=) | `80.00% <ø> (+3.63%)` | :arrow_up: |
| [cluster/loadbalance/ringhash/ringhash.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS9yaW5naGFzaC9yaW5naGFzaC5nbw==) | `63.33% <ø> (ø)` | |
| [cluster/router/tag/match.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdGFnL21hdGNoLmdv) | `90.69% <ø> (ø)` | |
| [cluster/router/tag/router.go](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9yb3V0ZXIvdGFnL3JvdXRlci5nbw==) | `59.64% <ø> (ø)` | |
| ... and [133 more](https://codecov.io/gh/apache/dubbo-go/pull/1963/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1963?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1963?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [53221fa...2d122f5](https://codecov.io/gh/apache/dubbo-go/pull/1963?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] cjphaha commented on a diff in pull request #1963: [WIP] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
cjphaha commented on code in PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963#discussion_r924623162
##########
metadata/service/remote/service.go:
##########
@@ -109,7 +109,9 @@ func (s *MetadataService) PublishServiceDefinition(url *common.URL) error {
if common.RoleType(common.PROVIDER).Role() == url.GetParam(constant.SideKey, "") {
if len(interfaceName) > 0 && !isGeneric {
sv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
- sd := definition.BuildServiceDefinition(*sv, url)
+ // sd := definition.BuildServiceDefinition(*sv, url)
+ // Waiting to be uncommented when passing sufficient tests
Review Comment:
The code commented out here can be deleted
##########
metadata/service/local/service.go:
##########
@@ -202,7 +202,9 @@ func (mts *MetadataService) PublishServiceDefinition(url *common.URL) error {
isGeneric := url.GetParamBool(constant.GenericKey, false)
if len(interfaceName) > 0 && !isGeneric {
tmpService := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
- sd := definition.BuildServiceDefinition(*tmpService, url)
+ // sd := definition.BuildServiceDefinition(*tmpService, url)
+ // Waiting to be uncommented when passing sufficient tests
Review Comment:
The code commented out here can be deleted
##########
metadata/definition/definition.go:
##########
@@ -121,6 +122,54 @@ func BuildServiceDefinition(service common.Service, url *common.URL) *ServiceDef
return sd
}
+func BuildFullDefinition(service common.Service, url *common.URL) *FullServiceDefinition {
Review Comment:
Please add a comment above the function, such as
```go
// BuildFullDefinition ...
func BuildFullDefinition(service common.Service, url *common.URL)
```
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] Leospard commented on a diff in pull request #1963: [Ftr] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
Leospard commented on code in PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963#discussion_r939478970
##########
metadata/definition/definition.go:
##########
@@ -70,8 +71,8 @@ func (def *ServiceDefinition) String() string {
// FullServiceDefinition is the describer of service definition with parameters
type FullServiceDefinition struct {
+ Parameters map[string]string
Review Comment:
主要是和java对齐,java里MetadataService服务提供的ServideDefinition是包含url Parameters参数的
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks commented on a diff in pull request #1963: [Ftr] Enhance ServiceDefinition in MetadataService
Posted by GitBox <gi...@apache.org>.
AlexStocks commented on code in PR #1963:
URL: https://github.com/apache/dubbo-go/pull/1963#discussion_r938395538
##########
metadata/definition/definition.go:
##########
@@ -70,8 +71,8 @@ func (def *ServiceDefinition) String() string {
// FullServiceDefinition is the describer of service definition with parameters
type FullServiceDefinition struct {
+ Parameters map[string]string
Review Comment:
这个 change 没看出来有啥意义
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org