Oxidaner commented on code in PR #3711:
URL: https://github.com/apache/dubbo-go/pull/3711#discussion_r3923915673


##########
metadata/definition/definition.go:
##########
@@ -0,0 +1,117 @@
+/*
+ * 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 definition builds and publishes interface-level service definitions.
+//
+// A service definition describes the RPC contract of a single exported service
+// interface: its methods, their signatures, and the structure of every type
+// reachable from those signatures. Dubbo Admin consumes these definitions to
+// render service documentation and to build generic-invocation request 
schemas.
+//
+// The JSON produced here is wire-compatible with Java's FullServiceDefinition
+// (dubbo-common/.../definition/model/), because Admin deserializes both into 
the
+// same ServiceProviderMetadata structure. Nothing in this package imports 
Admin
+// code — the compatibility contract is the JSON shape alone, pinned by the
+// golden tests in json_test.go.
+package definition
+
+// ServiceDefinition is the interface-level contract published for one exported
+// service. It mirrors Java's FullServiceDefinition.
+//
+// Java's codeSource field is deliberately omitted: Admin never reads it, and 
Go
+// has no equivalent notion of a class file origin.
+type ServiceDefinition struct {
+       // CanonicalName is the service interface name, always taken verbatim 
from
+       // the exported URL's Interface(). See BuildFromURL for why this must 
not be
+       // re-derived by reflection.
+       CanonicalName string `json:"canonicalName"`
+       // Methods holds one entry per canonical method the builder considers 
safe to
+       // expose. This is not the same set as Parameters["methods"]; see 
Parameters.
+       Methods []MethodDefinition `json:"methods"`
+       // Parameters carries the full provider URL parameter map, matching 
Java's
+       // serviceDefinition.setParameters(url.getParameters()).
+       //
+       // Parameters["methods"] is the runtime method set from the exported 
URL and
+       // includes the SwapCaseFirstRune aliases dubbo-go registers for Java
+       // interop. Methods above holds only canonical names. The two 
intentionally
+       // differ in size; consumers must not assume they match.
+       Parameters map[string]string `json:"parameters"`
+       // Types holds one entry for every composite type reachable from a 
method
+       // signature, including struct, slice, array and map shapes. Pointers 
express
+       // nullability and are folded into Java reference/wrapper spellings.
+       Types []TypeDefinition `json:"types"`
+}
+
+// MethodDefinition describes a single RPC method's signature.
+type MethodDefinition struct {
+       // Name is the canonical wire name: the MethodMapper mapping when one 
exists,
+       // otherwise the Go exported method name. The SwapCaseFirstRune alias is
+       // never published here even though it is routable at runtime.
+       Name string `json:"name"`
+       // ParameterTypes holds the type expression of each parameter, in order,
+       // excluding the receiver and a leading context.Context.
+       ParameterTypes []string `json:"parameterTypes"`
+       // Parameters pairs each parameter type with a positional name.
+       //
+       // Java's equivalent field is @Deprecated and carries TypeDefinition 
elements
+       // with no name at all. Go publishes {name, type} instead because 
Admin's
+       // Parameter message has both fields, and Go reflection cannot recover 
source
+       // parameter names — so the names here are always generated 
(arg0..argN).
+       Parameters []ParameterDefinition `json:"parameters"`
+       // ReturnType is the type expression of the non-error return value, or
+       // VoidReturnType for a method that returns only error.
+       ReturnType string `json:"returnType"`

Review Comment:
   ok, i  will revise it.



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

Reply via email to