feat:Solving Circular Dependency in Dubbo-Go (#2576)

* Solving Circular Dependency in Dubbo-Go

* fix test

* modify comment

* modify comment

* fix test
diff --git a/internal/internal.go b/internal/internal.go
new file mode 100644
index 0000000..983a28d
--- /dev/null
+++ b/internal/internal.go
@@ -0,0 +1,35 @@
+/*
+ * 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 internal contains dubbo-go-internal code, to avoid polluting
+// the top-level dubbo-go package.  It must not import any dubbo-go symbols
+// except internal symbols to avoid circular dependencies.
+package internal
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/internal/reflection"
+)
+
+var (
+	// HealthSetServingStatusServing is used to set service serving status
+	// the initialization place is in /protocol/triple/health/healthServer.go
+	HealthSetServingStatusServing = func(service string) {}
+	// ReflectionRegister is used to register reflection service provider
+	// the initialization place is in /protocol/triple/reflection/serverreflection.go
+	ReflectionRegister = func(reflection reflection.ServiceInfoProvider) {}
+	// todo: add metadata func
+)
diff --git a/internal/reflection/api.go b/internal/reflection/api.go
new file mode 100644
index 0000000..0f7bfd7
--- /dev/null
+++ b/internal/reflection/api.go
@@ -0,0 +1,38 @@
+/*
+ * 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 reflection
+
+import (
+	"google.golang.org/grpc"
+)
+
+// ServiceInfoProvider is an interface used to retrieve metadata about the
+// services to expose.
+//
+// The reflection service is only interested in the service names, but the
+// signature is this way so that *grpc.Server implements it. So it is okay
+// for a custom implementation to return zero values for the
+// grpc.ServiceInfo values in the map.
+//
+// # Experimental
+//
+// Notice: This type is EXPERIMENTAL and may be changed or removed in a
+// later release.
+type ServiceInfoProvider interface {
+	GetServiceInfo() map[string]grpc.ServiceInfo
+}
diff --git a/protocol/triple/health/healthServer.go b/protocol/triple/health/healthServer.go
index af2e69e..aca420d 100644
--- a/protocol/triple/health/healthServer.go
+++ b/protocol/triple/health/healthServer.go
@@ -32,6 +32,7 @@
 import (
 	"dubbo.apache.org/dubbo-go/v3/common/constant"
 	"dubbo.apache.org/dubbo-go/v3/config"
+	"dubbo.apache.org/dubbo-go/v3/internal"
 	"dubbo.apache.org/dubbo-go/v3/protocol/triple/health/triple_health"
 	"dubbo.apache.org/dubbo-go/v3/server"
 )
@@ -171,6 +172,9 @@
 
 func init() {
 	healthServer = NewServer()
+
+	internal.HealthSetServingStatusServing = SetServingStatusServing
+
 	server.SetProServices(&server.ServiceDefinition{
 		Handler: healthServer,
 		Info:    &triple_health.Health_ServiceInfo,
diff --git a/protocol/triple/reflection/serverreflection.go b/protocol/triple/reflection/serverreflection.go
index ae7bd09..dff1821 100644
--- a/protocol/triple/reflection/serverreflection.go
+++ b/protocol/triple/reflection/serverreflection.go
@@ -25,12 +25,9 @@
 )
 
 import (
-	"google.golang.org/grpc"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
-
 	"google.golang.org/protobuf/proto"
-
 	"google.golang.org/protobuf/reflect/protodesc"
 	"google.golang.org/protobuf/reflect/protoreflect"
 	"google.golang.org/protobuf/reflect/protoregistry"
@@ -39,26 +36,12 @@
 import (
 	"dubbo.apache.org/dubbo-go/v3/common/constant"
 	"dubbo.apache.org/dubbo-go/v3/config"
+	"dubbo.apache.org/dubbo-go/v3/internal"
+	"dubbo.apache.org/dubbo-go/v3/internal/reflection"
 	rpb "dubbo.apache.org/dubbo-go/v3/protocol/triple/reflection/triple_reflection"
 	"dubbo.apache.org/dubbo-go/v3/server"
 )
 
-// ServiceInfoProvider is an interface used to retrieve metadata about the
-// services to expose.
-//
-// The reflection service is only interested in the service names, but the
-// signature is this way so that *grpc.Server implements it. So it is okay
-// for a custom implementation to return zero values for the
-// grpc.ServiceInfo values in the map.
-//
-// # Experimental
-//
-// Notice: This type is EXPERIMENTAL and may be changed or removed in a
-// later release.
-type ServiceInfoProvider interface {
-	GetServiceInfo() map[string]grpc.ServiceInfo
-}
-
 // ExtensionResolver is the interface used to query details about extensions.
 // This interface is satisfied by protoregistry.GlobalTypes.
 //
@@ -79,7 +62,7 @@
 }
 
 type ReflectionServer struct {
-	s            ServiceInfoProvider
+	s            reflection.ServiceInfoProvider
 	descResolver protodesc.Resolver
 	extResolver  ExtensionResolver
 }
@@ -279,6 +262,7 @@
 
 func init() {
 	reflectionServer = NewServer()
+	internal.ReflectionRegister = Register
 	server.SetProServices(&server.ServiceDefinition{
 		Handler: reflectionServer,
 		Info:    &rpb.ServerReflection_ServiceInfo,
@@ -290,6 +274,6 @@
 	config.SetProviderServiceWithInfo(reflectionServer, &rpb.ServerReflection_ServiceInfo)
 }
 
-func Register(s ServiceInfoProvider) {
+func Register(s reflection.ServiceInfoProvider) {
 	reflectionServer.s = s
 }
diff --git a/protocol/triple/server.go b/protocol/triple/server.go
index 70ca805..1a403cc 100644
--- a/protocol/triple/server.go
+++ b/protocol/triple/server.go
@@ -38,10 +38,10 @@
 	"dubbo.apache.org/dubbo-go/v3/common"
 	"dubbo.apache.org/dubbo-go/v3/common/constant"
 	"dubbo.apache.org/dubbo-go/v3/config"
+	"dubbo.apache.org/dubbo-go/v3/internal"
 	"dubbo.apache.org/dubbo-go/v3/protocol"
 	"dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
 	"dubbo.apache.org/dubbo-go/v3/protocol/invocation"
-	"dubbo.apache.org/dubbo-go/v3/protocol/triple/reflection"
 	tri "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
 	"dubbo.apache.org/dubbo-go/v3/server"
 )
@@ -94,7 +94,7 @@
 		// old triple idl mode and non-idl mode
 		s.compatHandleService(intfName, URL.Group(), URL.Version(), hanOpts...)
 	}
-	reflection.Register(s)
+	internal.ReflectionRegister(s)
 
 	go func() {
 		if runErr := s.triServer.Run(); runErr != nil {
diff --git a/protocol/triple/triple.go b/protocol/triple/triple.go
index 74bd772..9ee503f 100644
--- a/protocol/triple/triple.go
+++ b/protocol/triple/triple.go
@@ -29,8 +29,8 @@
 	"dubbo.apache.org/dubbo-go/v3/common"
 	"dubbo.apache.org/dubbo-go/v3/common/constant"
 	"dubbo.apache.org/dubbo-go/v3/common/extension"
+	"dubbo.apache.org/dubbo-go/v3/internal"
 	"dubbo.apache.org/dubbo-go/v3/protocol"
-	"dubbo.apache.org/dubbo-go/v3/protocol/triple/health"
 	"dubbo.apache.org/dubbo-go/v3/server"
 )
 
@@ -66,7 +66,7 @@
 	tp.SetExporterMap(serviceKey, exporter)
 	logger.Infof("[TRIPLE Protocol] Export service: %s", url.String())
 	tp.openServer(invoker, info)
-	health.SetServingStatusServing(url.Service())
+	internal.HealthSetServingStatusServing(url.Service())
 	return exporter
 }
 
@@ -80,7 +80,7 @@
 	tp.SetExporterMap(serviceKey, exporter)
 	logger.Infof("[TRIPLE Protocol] Export service: %s", url.String())
 	tp.openServer(invoker, info)
-	health.SetServingStatusServing(url.Service())
+	internal.HealthSetServingStatusServing(url.Service())
 	return exporter
 }