AsperforMias opened a new pull request, #3796:
URL: https://github.com/apache/dubbo-go/pull/3796
### Description
Fixes #3795
Triple IDL services were excluded from ServiceDefinition publishing
(`describable` returned false and `TestTripleIDLIsNotPublished` pinned it), so
dubbo-admin could not list them or show their methods. This PR describes them
from protobuf descriptors.
**What changes**
- `describable` now accepts Triple IDL exports. `definition.BuildFromURL`
routes any Triple URL that carries a `ServiceInfo` to a new descriptor-based
builder (`metadata/definition/protobuf.go`). Dubbo and non-IDL Triple keep
using reflection unchanged, and REST and gRPC are still skipped.
- Request types come from each method's `ReqInitFunc`. Response types come
from the service descriptor that the generated `.pb.go` registers. When that
descriptor's input type disagrees with `ReqInitFunc`, the method is skipped
instead of guessed. A hand-written `ServiceInfo` with no registered descriptor
falls back to the handler method's return type.
**Design decisions**
1. *Protobuf full names for messages and enums.* Triple IDL generic
invocation identifies a message by its full name. The definition exists so
Admin can build those calls, so the names must match. A Go type name or a Java
class name would not resolve.
2. *Java vocabulary for scalars and containers.* Proto scalar names
(`string`, `int64`) were considered, since they would look more natural next to
proto message names. They were rejected for one reason: Admin's method detail
resolves types by exact string, and its debug form only generates default
values for `java.lang.String`, `int`, `long`, and so on. Any other scalar
renders as `null`. Java Dubbo's `ProtobufTypeBuilder` emits the same vocabulary
from the generated Java classes, so a Go provider and a Java provider of the
same proto now describe it the same way.
- Unsigned and fixed-width integers collapse to `int`/`long`, as in
generated Java code.
- Container elements are boxed (`java.util.List<java.lang.Integer>`),
because a Java generic cannot hold a primitive.
- Repeated fields are written as `java.util.List<T>`, not the `T[]` the
reflection builder uses for Go slices, because that is how Java exposes them.
- `bytes` has no entry Admin understands and stays `bytes`.
3. *Unary only.* Admin generic invocation is unary-only, so streaming
methods are skipped and reported as skipped methods.
4. *Oneofs are flattened.* Every member becomes an ordinary property. The
definition format cannot express "at most one of".
**Known limitations**
- If an IDL service is also exported over Dubbo, the existing
lowest-protocol rule keeps the reflection-built document. This was left as is
so that selection stays a pure function of the URLs. The combination is rare,
and both documents list the same methods.
- Admin's debug form renders map fields as `[]` and `bytes` fields as
`null`. Those are Admin-side templating gaps.
- Only the Nacos publisher exists today. The ZooKeeper publisher is a
separate PR, and etcd is not covered yet.
**Verification**
- Unit tests cover scalars, enums, nested messages, repeated fields, maps,
oneofs, well-known types (`Empty`, `Timestamp`, `StringValue`), a recursive
message, streaming skips, a `ReqInitFunc` mismatch, and boxing of container
elements. `TestTripleIDLIsNotPublished` is replaced by
`TestTripleIDLUnaryIsPublished`.
- End-to-end against dubbo-admin `develop`, with the IDL `GreetService`
provider from dubbo-go-samples, on Nacos and on ZooKeeper (with the ZK
publisher applied separately). For each, service search, service detail,
`/service/methods`, and method detail return the service, the `Greet` method,
its request/response types, and their fields.
### Checklist
- [ ] I confirm the target branch is `develop`
- [x] I have run `make fmt` to format my code
- [x] I have run `make test` to run local tests
- [x] I have added tests that prove my fix is effective or that my feature
works
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]