diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3bd8d9cb19..6053bf9829 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,5 +16,5 @@ updates: # default location of `.github/workflows` directory: "/" schedule: - interval: "weekly" + interval: "monthly" target-branch: "3.0" diff --git a/CHANGELOG.md b/CHANGELOG.md index e40a5cdf6d..93c1493b7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Release Notes --- +## 3.0.2 + +### Features + +- [Support hessian java method java.lang param](https://github.com/apache/dubbo-go/pull/1783) +- [Support istio xds](https://github.com/apache/dubbo-go/pull/1804) +- [Support istio xds ring hash](https://github.com/apache/dubbo-go/pull/1828) +- [Support otel trace](https://github.com/apache/dubbo-go/pull/1886) + +### Bugfixs + +- [Fix: where limitation not updates](https://github.com/apache/dubbo-go/pull/1784) +- [Fix: rootConfig and getty-session-param](https://github.com/apache/dubbo-go/pull/1802) +- [Fix: xds adsz empty metadata](https://github.com/apache/dubbo-go/pull/1813) +- [Fix: decode net stream bytes as getty rule](https://github.com/apache/dubbo-go/pull/1820) +- [Fix: ip register issue](https://github.com/apache/dubbo-go/pull/1821) +- [Fix: getty unit test](https://github.com/apache/dubbo-go/pull/1829) +- [Fix: remove HEADER_LENGTH in decode because of discard](https://github.com/apache/dubbo-go/pull/1831) +- [Fix: xds log use dubbogo logger](https://github.com/apache/dubbo-go/pull/1846) +- [Fix: limit rpc package data size by user's config rather than DEFAULT_LEN](https://github.com/apache/dubbo-go/pull/1848) +- [Fix: complete grpc based protocol panic recover handle](https://github.com/apache/dubbo-go/pull/1866) + +### Enhancements + +- [Add req.Data to OnMessage panic error log](https://github.com/apache/dubbo-go/pull/1847) +- [Add nacos updateCacheWhenEmpty options](https://github.com/apache/dubbo-go/pull/1852) +- [Xds enhancement](https://github.com/apache/dubbo-go/pull/1853) +- [Mock etcd and nacos in ut](https://github.com/apache/dubbo-go/pull/1873) +- [Use summary type to observe p99](https://github.com/apache/dubbo-go/pull/1875) +- [Remove gomonkey](https://github.com/apache/dubbo-go/pull/1881) +- [Optimized load balancing algorithm](https://github.com/apache/dubbo-go/pull/1884) +- [RandomLoadBalance code optimization](https://github.com/apache/dubbo-go/pull/1899) +- [Export hessian type api](https://github.com/apache/dubbo-go/pull/1911) +- [Export method getArgsTypeList for extension](https://github.com/apache/dubbo-go/pull/1913) + ## 3.0.1 diff --git a/README.md b/README.md index d97918d095..bb92459f1d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Dubbo-go has supported many RPC protocol, like Triple, Dubbo JSONRPC, gRPC, HTTP ![](https://dubbogo.github.io/img/devops.png) - **Registry**: Nacos, Zookeeper, ETCD, Polaris-mesh, Consul. -- **ConfigCenter**: Nacos, Apollo, Zookeeper +- **ConfigCenter**: Nacos, Zookeeper - **Cluster Strategy**: Failover, [Failfast](https://github.com/apache/dubbo-go/pull/140), [Failsafe/Failback](https://github.com/apache/dubbo-go/pull/136), [Available](https://github.com/apache/dubbo-go/pull/155), [Broadcast](https://github.com/apache/dubbo-go/pull/158), [Forking](https://github.com/apache/dubbo-go/pull/161) - **Load Balance**: [AdaptiveService](https://github.com/apache/dubbo-go/pull/1649), Random, [RoundRobin](https://github.com/apache/dubbo-go/pull/66), [LeastActive](https://github.com/apache/dubbo-go/pull/65), [ConsistentHash](https://github.com/apache/dubbo-go/pull/261) - [**Filter**](./filter): Echo, Hystrix, Token, AccessLog, TpsLimiter, ExecuteLimit, Generic, Auth/Sign, Metrics, Tracing, Active, Seata, Sentinel diff --git a/README_CN.md b/README_CN.md index a87921bf16..217e5e4da0 100644 --- a/README_CN.md +++ b/README_CN.md @@ -32,7 +32,7 @@ Dubbo-go 生态覆盖多种网络协议:Triple、Dubbo、JSONRPC、gRPC、HTTP - **配置中心** - 开发者可以使用Nacos、Apollo(携程开源)、Zookeeper 进行框架/用户的配置的发布和拉取。 + 开发者可以使用Nacos、Zookeeper 进行框架/用户的配置的发布和拉取。 - **集群策略**: Failover, [Failfast](https://github.com/apache/dubbo-go/pull/140), [Failsafe/Failback](https://github.com/apache/dubbo-go/pull/136), [Available](https://github.com/apache/dubbo-go/pull/155), [Broadcast](https://github.com/apache/dubbo-go/pull/158), [Forking](https://github.com/apache/dubbo-go/pull/161) 等 diff --git a/cluster/cluster/adaptivesvc/cluster_invoker.go b/cluster/cluster/adaptivesvc/cluster_invoker.go index 64fa272bbc..7eaf456e8a 100644 --- a/cluster/cluster/adaptivesvc/cluster_invoker.go +++ b/cluster/cluster/adaptivesvc/cluster_invoker.go @@ -23,6 +23,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -33,7 +35,6 @@ import ( clsutils "dubbo.apache.org/dubbo-go/v3/cluster/utils" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/base/cluster_invoker.go b/cluster/cluster/base/cluster_invoker.go index facb1e6e2d..2d01fad84b 100644 --- a/cluster/cluster/base/cluster_invoker.go +++ b/cluster/cluster/base/cluster_invoker.go @@ -19,6 +19,8 @@ package base import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" "go.uber.org/atomic" @@ -30,7 +32,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/broadcast/cluster_invoker.go b/cluster/cluster/broadcast/cluster_invoker.go index a0ee7c7230..16850a5c00 100644 --- a/cluster/cluster/broadcast/cluster_invoker.go +++ b/cluster/cluster/broadcast/cluster_invoker.go @@ -21,10 +21,13 @@ import ( "context" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/failback/cluster_invoker.go b/cluster/cluster/failback/cluster_invoker.go index 71b260f3e1..f647e33a60 100644 --- a/cluster/cluster/failback/cluster_invoker.go +++ b/cluster/cluster/failback/cluster_invoker.go @@ -26,6 +26,8 @@ import ( import ( "github.com/Workiva/go-datastructures/queue" + + "github.com/dubbogo/gost/log/logger" ) import ( @@ -34,7 +36,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/failover/cluster_invoker.go b/cluster/cluster/failover/cluster_invoker.go index d217fa4c90..0d6db65c7e 100644 --- a/cluster/cluster/failover/cluster_invoker.go +++ b/cluster/cluster/failover/cluster_invoker.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -32,7 +34,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/failsafe/cluster_invoker.go b/cluster/cluster/failsafe/cluster_invoker.go index 660822e7e9..95b109868a 100644 --- a/cluster/cluster/failsafe/cluster_invoker.go +++ b/cluster/cluster/failsafe/cluster_invoker.go @@ -21,12 +21,15 @@ import ( "context" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/forking/cluster_invoker.go b/cluster/cluster/forking/cluster_invoker.go index ad2dc4d25f..2c35a9493f 100644 --- a/cluster/cluster/forking/cluster_invoker.go +++ b/cluster/cluster/forking/cluster_invoker.go @@ -25,13 +25,14 @@ import ( import ( "github.com/Workiva/go-datastructures/queue" + + "github.com/dubbogo/gost/log/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/cluster/mock.go b/cluster/cluster/mock.go index 77d3829d52..943fcf380c 100644 --- a/cluster/cluster/mock.go +++ b/cluster/cluster/mock.go @@ -22,13 +22,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/loadbalance/p2c/loadbalance.go b/cluster/loadbalance/p2c/loadbalance.go index 3e40fa4861..7a044cc55f 100644 --- a/cluster/loadbalance/p2c/loadbalance.go +++ b/cluster/loadbalance/p2c/loadbalance.go @@ -25,12 +25,15 @@ import ( "time" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" "dubbo.apache.org/dubbo-go/v3/cluster/metrics" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/loadbalance/ringhash/ringhash.go b/cluster/loadbalance/ringhash/ringhash.go index 3bd5f085f9..7ad96f5986 100644 --- a/cluster/loadbalance/ringhash/ringhash.go +++ b/cluster/loadbalance/ringhash/ringhash.go @@ -21,12 +21,15 @@ import ( "strconv" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/remoting/xds" ) diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 3ed67a919f..037fa5554f 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -23,6 +23,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" "go.uber.org/atomic" @@ -32,7 +34,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/config_center/apollo/doc.go b/cluster/router/meshrouter/factory.go similarity index 53% rename from config_center/apollo/doc.go rename to cluster/router/meshrouter/factory.go index a94ed5f448..773aa4b7b9 100644 --- a/config_center/apollo/doc.go +++ b/cluster/router/meshrouter/factory.go @@ -15,5 +15,27 @@ * limitations under the License. */ -// Package apollo implements config center around Apollo. -package apollo +package meshrouter + +import ( + "dubbo.apache.org/dubbo-go/v3/cluster/router" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/extension" +) + +func init() { + extension.SetRouterFactory(constant.MeshRouterFactoryKey, NewMeshRouterFactory) +} + +// MeshRouterFactory is mesh router's factory +type MeshRouterFactory struct{} + +// NewMeshRouterFactory constructs a new PriorityRouterFactory +func NewMeshRouterFactory() router.PriorityRouterFactory { + return &MeshRouterFactory{} +} + +// NewPriorityRouter construct a new UniformRouteFactory as PriorityRouter +func (f *MeshRouterFactory) NewPriorityRouter() (router.PriorityRouter, error) { + return NewMeshRouter() +} diff --git a/cluster/router/meshrouter/meshrouter.go b/cluster/router/meshrouter/meshrouter.go new file mode 100644 index 0000000000..7a174f30b7 --- /dev/null +++ b/cluster/router/meshrouter/meshrouter.go @@ -0,0 +1,149 @@ +/* + * 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 meshrouter + +import ( + "math/rand" +) + +import ( + "github.com/dubbogo/gost/log/logger" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/cluster/router" + "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/config_center" + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/remoting/xds" +) + +const ( + name = "mesh-router" +) + +// MeshRouter have +type MeshRouter struct { + client *xds.WrappedClientImpl +} + +// NewMeshRouter construct an NewConnCheckRouter via url +func NewMeshRouter() (router.PriorityRouter, error) { + xdsWrappedClient := xds.GetXDSWrappedClient() + if xdsWrappedClient == nil { + logger.Debugf("[Mesh Router] xds wrapped client is not created.") + } + return &MeshRouter{ + client: xdsWrappedClient, + }, nil +} + +// Route gets a list of routed invoker +func (r *MeshRouter) Route(invokers []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker { + if r.client == nil { + return invokers + } + hostAddr, err := r.client.GetHostAddrByServiceUniqueKey(common.GetSubscribeName(url)) + if err != nil { + // todo deal with error + return nil + } + rconf := r.client.GetRouterConfig(hostAddr) + + clusterInvokerMap := make(map[string][]protocol.Invoker) + for _, v := range invokers { + meshClusterID := v.GetURL().GetParam(constant.MeshClusterIDKey, "") + if _, ok := clusterInvokerMap[meshClusterID]; !ok { + clusterInvokerMap[meshClusterID] = make([]protocol.Invoker, 0) + } + clusterInvokerMap[meshClusterID] = append(clusterInvokerMap[meshClusterID], v) + } + route, err := r.client.MatchRoute(rconf, invocation) + if err != nil { + logger.Errorf("[Mesh Router] not found route,method=%s", invocation.MethodName()) + return nil + } + + // Loop through routes in order and select first match. + if route == nil || route.WeightedClusters == nil { + logger.Errorf("[Mesh Router] route's WeightedClusters is empty, route: %+v", r) + return invokers + } + invokersWeightPairs := make(invokerWeightPairs, 0) + + for clusterID, weight := range route.WeightedClusters { + // cluster -> invokers + targetInvokers := clusterInvokerMap[clusterID] + invokersWeightPairs = append(invokersWeightPairs, invokerWeightPair{ + invokers: targetInvokers, + weight: weight.Weight, + }) + } + return invokersWeightPairs.GetInvokers() +} + +// Process there is no process needs for uniform Router, as it upper struct RouterChain has done it +func (r *MeshRouter) Process(event *config_center.ConfigChangeEvent) { +} + +// Name get name of ConnCheckerRouter +func (r *MeshRouter) Name() string { + return name +} + +// Priority get Router priority level +func (r *MeshRouter) Priority() int64 { + return 0 +} + +// URL Return URL in router +func (r *MeshRouter) URL() *common.URL { + return nil +} + +// Notify the router the invoker list +func (r *MeshRouter) Notify(invokers []protocol.Invoker) { +} + +type invokerWeightPair struct { + invokers []protocol.Invoker + weight uint32 +} + +type invokerWeightPairs []invokerWeightPair + +func (i *invokerWeightPairs) GetInvokers() []protocol.Invoker { + if len(*i) == 0 { + return nil + } + totalWeight := uint32(0) + tempWeight := uint32(0) + for _, v := range *i { + totalWeight += v.weight + } + randFloat := rand.Float64() + for _, v := range *i { + tempWeight += v.weight + tempPercent := float64(tempWeight) / float64(totalWeight) + if tempPercent >= randFloat { + return v.invokers + } + } + return (*i)[0].invokers +} diff --git a/cluster/router/tag/match.go b/cluster/router/tag/match.go index 07e686b57b..f9f900e032 100644 --- a/cluster/router/tag/match.go +++ b/cluster/router/tag/match.go @@ -21,10 +21,13 @@ import ( "strconv" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/cluster/router/tag/router.go b/cluster/router/tag/router.go index 207443646f..d728772b9d 100644 --- a/cluster/router/tag/router.go +++ b/cluster/router/tag/router.go @@ -23,6 +23,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "gopkg.in/yaml.v2" ) @@ -30,7 +32,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" conf "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/common/file/suffix.go b/common/constant/file/suffix.go similarity index 100% rename from common/file/suffix.go rename to common/constant/file/suffix.go diff --git a/common/constant/key.go b/common/constant/key.go index 7cea915e76..4fd53cdb71 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -305,6 +305,7 @@ const ( Tagkey = "dubbo.tag" // key of tag AttachmentKey = DubboCtxKey("attachment") // key in context in invoker TagRouterFactoryKey = "tag" + MeshRouterFactoryKey = "mesh" ) // Auth filter @@ -370,6 +371,12 @@ const ( // reflection service const ( - ReflectionServiceTypeName = "XXX_serverReflectionServer" + ReflectionServiceTypeName = "DubbogoServerReflectionServer" ReflectionServiceInterface = "grpc.reflection.v1alpha.ServerReflection" ) + +// healthcheck service +const ( + HealthCheckServiceTypeName = "DubbogoHealthServer" + HealthCheckServiceInterface = "grpc.health.v1.Health" +) diff --git a/common/extension/proxy_factory.go b/common/extension/proxy_factory.go index f9e6246620..5dfe0c9da5 100644 --- a/common/extension/proxy_factory.go +++ b/common/extension/proxy_factory.go @@ -18,8 +18,11 @@ package extension import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/proxy" + "github.com/dubbogo/gost/log/logger" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/proxy" ) var proxyFactories = make(map[string]func(...proxy.Option) proxy.ProxyFactory) diff --git a/common/logger/file_log.yml b/common/logger/file_log.yml deleted file mode 100644 index 75cc32c7ea..0000000000 --- a/common/logger/file_log.yml +++ /dev/null @@ -1,36 +0,0 @@ -lumberjackConfig: - filename: "logs.log" - maxSize: 1 - maxAge: 3 - maxBackups: 5 - localTime: true - compress: false - -zapConfig: - level: "debug" - development: false - disableCaller: false - disableStacktrace: false - sampling: - encoding: "console" - - # encoder - encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capitalColor" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - - outputPaths: - - "stderr" - errorOutputPaths: - - "stderr" - initialFields: diff --git a/common/logger/logger.go b/common/logger/logger.go deleted file mode 100644 index 29d0278fab..0000000000 --- a/common/logger/logger.go +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 logger - -import ( - "github.com/apache/dubbo-getty" - - "github.com/natefinch/lumberjack" - - "go.uber.org/zap" - "go.uber.org/zap/zapcore" -) - -var logger Logger - -func init() { - InitLogger(nil) -} - -// nolint -type DubboLogger struct { - Logger - dynamicLevel zap.AtomicLevel -} - -type Config struct { - LumberjackConfig *lumberjack.Logger `yaml:"lumberjack-config"` - ZapConfig *zap.Config `yaml:"zap-config"` - CallerSkip int -} - -// Logger is the interface for Logger types -type Logger interface { - Info(args ...interface{}) - Warn(args ...interface{}) - Error(args ...interface{}) - Debug(args ...interface{}) - Fatal(args ...interface{}) - - Infof(fmt string, args ...interface{}) - Warnf(fmt string, args ...interface{}) - Errorf(fmt string, args ...interface{}) - Debugf(fmt string, args ...interface{}) - Fatalf(fmt string, args ...interface{}) -} - -// InitLogger use for init logger by @conf -func InitLogger(conf *Config) { - var ( - zapLogger *zap.Logger - config = &Config{} - ) - if conf == nil || conf.ZapConfig == nil { - zapLoggerEncoderConfig := zapcore.EncoderConfig{ - TimeKey: "time", - LevelKey: "level", - NameKey: "logger", - CallerKey: "caller", - MessageKey: "message", - StacktraceKey: "stacktrace", - EncodeLevel: zapcore.CapitalColorLevelEncoder, - EncodeTime: zapcore.ISO8601TimeEncoder, - EncodeDuration: zapcore.SecondsDurationEncoder, - EncodeCaller: zapcore.ShortCallerEncoder, - } - config.ZapConfig = &zap.Config{ - Level: zap.NewAtomicLevelAt(zap.InfoLevel), - Development: false, - Encoding: "console", - EncoderConfig: zapLoggerEncoderConfig, - OutputPaths: []string{"stderr"}, - ErrorOutputPaths: []string{"stderr"}, - } - } else { - config.ZapConfig = conf.ZapConfig - } - - if conf != nil { - config.CallerSkip = conf.CallerSkip - } - - if config.CallerSkip == 0 { - config.CallerSkip = 1 - } - - if conf == nil || conf.LumberjackConfig == nil { - zapLogger, _ = config.ZapConfig.Build(zap.AddCaller(), zap.AddCallerSkip(config.CallerSkip)) - } else { - config.LumberjackConfig = conf.LumberjackConfig - zapLogger = initZapLoggerWithSyncer(config) - } - - logger = &DubboLogger{Logger: zapLogger.Sugar(), dynamicLevel: config.ZapConfig.Level} - - // set getty log - getty.SetLogger(logger) -} - -// SetLogger sets logger for dubbo and getty -func SetLogger(log Logger) { - logger = log - getty.SetLogger(logger) -} - -// GetLogger gets the logger -func GetLogger() Logger { - return logger -} - -// SetLoggerLevel use for set logger level -func SetLoggerLevel(level string) bool { - if l, ok := logger.(OpsLogger); ok { - l.SetLoggerLevel(level) - return true - } - return false -} - -// OpsLogger use for the SetLoggerLevel -type OpsLogger interface { - Logger - SetLoggerLevel(level string) -} - -// SetLoggerLevel use for set logger level -func (dl *DubboLogger) SetLoggerLevel(level string) { - l := new(zapcore.Level) - if err := l.Set(level); err == nil { - dl.dynamicLevel.SetLevel(*l) - } -} - -// initZapLoggerWithSyncer init zap Logger with syncer -func initZapLoggerWithSyncer(conf *Config) *zap.Logger { - core := zapcore.NewCore( - conf.getEncoder(), - conf.getLogWriter(), - zap.NewAtomicLevelAt(conf.ZapConfig.Level.Level()), - ) - - return zap.New(core, zap.AddCaller(), zap.AddCallerSkip(conf.CallerSkip)) -} - -// getEncoder get encoder by config, zapcore support json and console encoder -func (c *Config) getEncoder() zapcore.Encoder { - if c.ZapConfig.Encoding == "json" { - return zapcore.NewJSONEncoder(c.ZapConfig.EncoderConfig) - } else if c.ZapConfig.Encoding == "console" { - return zapcore.NewConsoleEncoder(c.ZapConfig.EncoderConfig) - } - return nil -} - -// getLogWriter get Lumberjack writer by LumberjackConfig -func (c *Config) getLogWriter() zapcore.WriteSyncer { - return zapcore.AddSync(c.LumberjackConfig) -} diff --git a/common/logger/logging.go b/common/logger/logging.go deleted file mode 100644 index d114423c3d..0000000000 --- a/common/logger/logging.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 logger - -// Info is info level -func Info(args ...interface{}) { - logger.Info(args...) -} - -// Warn is warning level -func Warn(args ...interface{}) { - logger.Warn(args...) -} - -// Error is error level -func Error(args ...interface{}) { - logger.Error(args...) -} - -// Debug is debug level -func Debug(args ...interface{}) { - logger.Debug(args...) -} - -// Infof is format info level -func Infof(fmt string, args ...interface{}) { - logger.Infof(fmt, args...) -} - -// Warnf is format warning level -func Warnf(fmt string, args ...interface{}) { - logger.Warnf(fmt, args...) -} - -// Errorf is format error level -func Errorf(fmt string, args ...interface{}) { - logger.Errorf(fmt, args...) -} - -// Debugf is format debug level -func Debugf(fmt string, args ...interface{}) { - logger.Debugf(fmt, args...) -} - -// Fatal logs a message, then calls os.Exit. -func Fatal(args ...interface{}) { - logger.Fatal(args...) -} - -// Fatalf logs a templated message, then calls os.Exit. -func Fatalf(fmt string, args ...interface{}) { - logger.Fatalf(fmt, args...) -} diff --git a/common/metadata_info.go b/common/metadata_info.go index 73670cf36a..b365a581b5 100644 --- a/common/metadata_info.go +++ b/common/metadata_info.go @@ -87,17 +87,17 @@ func (mi *MetadataInfo) CalAndGetRevision() string { if len(mi.Services) == 0 { return "0" } - candidates := make([]string, 8) + candidates := make([]string, 0, 8) for _, s := range mi.Services { - sk := s.ServiceKey + iface := s.URL.GetParam(constant.InterfaceKey, "") ms := s.URL.Methods if len(ms) == 0 { - candidates = append(candidates, sk) + candidates = append(candidates, iface) } else { for _, m := range ms { // methods are part of candidates - candidates = append(candidates, sk+constant.KeySeparator+m) + candidates = append(candidates, iface+constant.KeySeparator+m) } } diff --git a/common/observer/event.go b/common/observer/event.go deleted file mode 100644 index 209a50c78a..0000000000 --- a/common/observer/event.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 observer - -import ( - "fmt" - "math/rand" - "time" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -// Event is align with Event interface in Java. -// it's the top abstraction -// Align with 2.7.5 -type Event interface { - fmt.Stringer - GetSource() interface{} - GetTimestamp() time.Time -} - -// BaseEvent is the base implementation of Event -// You should never use it directly -type BaseEvent struct { - Source interface{} - Timestamp time.Time -} - -// GetSource return the source -func (b *BaseEvent) GetSource() interface{} { - return b.Source -} - -// GetTimestamp return the Timestamp when the event is created -func (b *BaseEvent) GetTimestamp() time.Time { - return b.Timestamp -} - -// String return a human readable string representing this event -func (b *BaseEvent) String() string { - return fmt.Sprintf("BaseEvent[source = %#v]", b.Source) -} - -// NewBaseEvent create an BaseEvent instance -// and the Timestamp will be current timestamp -func NewBaseEvent(source interface{}) *BaseEvent { - return &BaseEvent{ - Source: source, - Timestamp: time.Now(), - } -} diff --git a/common/observer/event_listener.go b/common/observer/event_listener.go deleted file mode 100644 index faa8705a42..0000000000 --- a/common/observer/event_listener.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 observer - -import ( - "reflect" -) - -import ( - gxsort "github.com/dubbogo/gost/sort" -) - -// EventListener is an new interface used to align with dubbo 2.7.5 -// It contains the Prioritized means that the listener has its priority -// Usually the priority of your custom implementation should be between [100, 9000] -// the number outside the range will be though as system reserve number -// usually implementation should be singleton -type EventListener interface { - gxsort.Prioritizer - // OnEvent handle this event - OnEvent(e Event) error - // GetEventType listen which event type - GetEventType() reflect.Type -} - -// ConditionalEventListener only handle the event which it can handle -type ConditionalEventListener interface { - EventListener - // Accept will make the decision whether it should handle this event - Accept(e Event) bool -} - -type ChangedNotify interface { - Notify(e Event) -} diff --git a/common/rpc_service.go b/common/rpc_service.go index 45c7df91b7..95b4845f90 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -27,11 +27,9 @@ import ( ) import ( - perrors "github.com/pkg/errors" -) + "github.com/dubbogo/gost/log/logger" -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + perrors "github.com/pkg/errors" ) // RPCService the type alias of interface{} diff --git a/common/yaml/testdata/config.yml b/common/yaml/testdata/config.yml deleted file mode 100644 index a56c842529..0000000000 --- a/common/yaml/testdata/config.yml +++ /dev/null @@ -1,7 +0,0 @@ - -intTest: 11 -booleanTest: false -strTest: "strTest" - -child: - strTest: "childStrTest" \ No newline at end of file diff --git a/common/yaml/yaml.go b/common/yaml/yaml.go deleted file mode 100644 index 1284395793..0000000000 --- a/common/yaml/yaml.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 yaml - -import ( - "io/ioutil" - "path" -) - -import ( - perrors "github.com/pkg/errors" - - "gopkg.in/yaml.v2" -) - -// LoadYMLConfig Load yml config byte from file -func LoadYMLConfig(confProFile string) ([]byte, error) { - if len(confProFile) == 0 { - return nil, perrors.Errorf("application configure(provider) file name is nil") - } - - if path.Ext(confProFile) != ".yml" { - return nil, perrors.Errorf("application configure file name{%v} suffix must be .yml", confProFile) - } - - return ioutil.ReadFile(confProFile) -} - -// UnmarshalYMLConfig Load yml config byte from file, then unmarshal to object -func UnmarshalYMLConfig(confProFile string, out interface{}) ([]byte, error) { - confFileStream, err := LoadYMLConfig(confProFile) - if err != nil { - return confFileStream, perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err)) - } - return confFileStream, yaml.Unmarshal(confFileStream, out) -} - -// UnmarshalYML unmarshals decodes the first document found within the in byte slice and assigns decoded values into the out value. -func UnmarshalYML(data []byte, out interface{}) error { - return yaml.Unmarshal(data, out) -} - -// MarshalYML serializes the value provided into a YAML document. -func MarshalYML(in interface{}) ([]byte, error) { - return yaml.Marshal(in) -} diff --git a/common/yaml/yaml_test.go b/common/yaml/yaml_test.go deleted file mode 100644 index 19f4fe148a..0000000000 --- a/common/yaml/yaml_test.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 yaml - -import ( - "path/filepath" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestUnmarshalYMLConfig(t *testing.T) { - conPath, err := filepath.Abs("./testdata/config.yml") - assert.NoError(t, err) - c := &Config{} - _, err = UnmarshalYMLConfig(conPath, c) - assert.NoError(t, err) - assert.Equal(t, "strTest", c.StrTest) - assert.Equal(t, 11, c.IntTest) - assert.Equal(t, false, c.BooleanTest) - assert.Equal(t, "childStrTest", c.ChildConfig.StrTest) -} - -func TestUnmarshalYMLConfigError(t *testing.T) { - c := &Config{} - _, err := UnmarshalYMLConfig("./testdata/config", c) - assert.Error(t, err) - _, err = UnmarshalYMLConfig("", c) - assert.Error(t, err) -} - -func TestUnmarshalYML(t *testing.T) { - c := &Config{} - b, err := LoadYMLConfig("./testdata/config.yml") - assert.NoError(t, err) - err = UnmarshalYML(b, c) - assert.NoError(t, err) - assert.Equal(t, "strTest", c.StrTest) - assert.Equal(t, 11, c.IntTest) - assert.Equal(t, false, c.BooleanTest) - assert.Equal(t, "childStrTest", c.ChildConfig.StrTest) -} - -type Config struct { - StrTest string `yaml:"strTest" default:"default" json:"strTest,omitempty" property:"strTest"` - IntTest int `default:"109" yaml:"intTest" json:"intTest,omitempty" property:"intTest"` - BooleanTest bool `yaml:"booleanTest" default:"true" json:"booleanTest,omitempty"` - ChildConfig ChildConfig `yaml:"child" json:"child,omitempty"` -} - -type ChildConfig struct { - StrTest string `default:"default" yaml:"strTest" json:"strTest,omitempty"` -} diff --git a/config/config_center_config.go b/config/config_center_config.go index 48baa80268..0bab9089ef 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -25,6 +25,8 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/log/logger" + "github.com/knadh/koanf" "github.com/pkg/errors" @@ -35,7 +37,6 @@ import ( conf "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" ) diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go deleted file mode 100644 index b32c4c5da8..0000000000 --- a/config/config_center_config_test.go +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" -) - -func TestApolloConfigCenterConfig(t *testing.T) { - - err := Load(WithPath("./testdata/config/center/apollo.yaml")) - assert.Nil(t, err) - - registries := rootConfig.Registries - assert.NotNil(t, registries) -} -func TestConfigCenterConfig(t *testing.T) { - var ( - config *CenterConfig - err error - ) - - t.Run("ConfigCenterConfigBuilder", func(t *testing.T) { - config = NewConfigCenterConfigBuilder(). - SetProtocol("protocol"). - SetUserName("userName"). - SetAddress("address"). - SetPassword("password"). - SetNamespace("namespace"). - SetGroup("group"). - SetDataID("dataId"). - Build() - - err = config.check() - assert.Nil(t, err) - - assert.Equal(t, config.Protocol, "protocol") - assert.Equal(t, config.Username, "userName") - assert.Equal(t, config.Address, "address") - assert.Equal(t, config.Password, "password") - assert.Equal(t, config.Namespace, "namespace") - assert.Equal(t, config.Group, "group") - assert.Equal(t, config.DataId, "dataId") - assert.Equal(t, config.Prefix(), constant.ConfigCenterPrefix) - //assert.Equal(t, config.NameId(), - // strings.Join([]string{constant.ConfigCenterPrefix, "protocol", "address"}, "-")) - }) - - t.Run("GetUrlMap", func(t *testing.T) { - url := config.GetUrlMap() - assert.Equal(t, url.Get(constant.ConfigNamespaceKey), config.Namespace) - assert.Equal(t, url.Get(constant.ConfigClusterKey), config.Cluster) - }) - - t.Run("translateConfigAddress", func(t *testing.T) { - address := config.translateConfigAddress() - assert.Equal(t, address, "address") - }) - - t.Run("toUrl", func(t *testing.T) { - url, err := config.toURL() - assert.Nil(t, err) - namespace := url.GetParam(constant.ConfigNamespaceKey, "namespace") - assert.Equal(t, namespace, "namespace") - }) -} diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 0f86300b7f..61554f0da8 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -26,6 +26,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/knadh/koanf" "github.com/pkg/errors" @@ -33,8 +35,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/file" - "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/common/constant/file" ) type loaderConf struct { diff --git a/config/config_loader_options_test.go b/config/config_loader_options_test.go index 2ace22b8b6..7c5e92b0e4 100644 --- a/config/config_loader_options_test.go +++ b/config/config_loader_options_test.go @@ -27,7 +27,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/file" + "dubbo.apache.org/dubbo-go/v3/common/constant/file" ) func TestCheckGenre(t *testing.T) { diff --git a/config/config_resolver.go b/config/config_resolver.go index f94fce2c2f..0e4eefd4a6 100644 --- a/config/config_resolver.go +++ b/config/config_resolver.go @@ -28,7 +28,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/file" + "dubbo.apache.org/dubbo-go/v3/common/constant/file" "dubbo.apache.org/dubbo-go/v3/config/parsers/properties" ) diff --git a/config/consumer_config.go b/config/consumer_config.go index af04775d72..2fcbb69774 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -25,13 +25,14 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/log/logger" + tripleConstant "github.com/dubbogo/triple/pkg/common/constant" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) const ( diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go index 3b0fb30a1f..6b81c5df10 100644 --- a/config/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -26,12 +26,12 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/log/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) /* diff --git a/config/graceful_shutdown_config.go b/config/graceful_shutdown_config.go index 9706ce8899..93d990dafa 100644 --- a/config/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -24,12 +24,13 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/log/logger" + "go.uber.org/atomic" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) const ( diff --git a/config/logger_config.go b/config/logger_config.go index 1050c0fb7a..30f7be1a42 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -24,6 +24,9 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/encoding/yaml" + "github.com/dubbogo/gost/log/logger" + "github.com/natefinch/lumberjack" "go.uber.org/zap" @@ -32,8 +35,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/yaml" ) type ZapConfig struct { diff --git a/config/logger_config_test.go b/config/logger_config_test.go index ed9ac24159..fdb9224cdd 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -22,11 +22,9 @@ import ( ) import ( - "github.com/stretchr/testify/assert" -) + "github.com/dubbogo/gost/log/logger" -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + "github.com/stretchr/testify/assert" ) func TestLoggerInit(t *testing.T) { diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 99845ee24b..837f7af8e0 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -18,6 +18,8 @@ package config import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -25,7 +27,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config/instance" ) diff --git a/config/provider_config.go b/config/provider_config.go index 0c024947c5..6ba917a611 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -24,6 +24,8 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/log/logger" + tripleConstant "github.com/dubbogo/triple/pkg/common/constant" perrors "github.com/pkg/errors" @@ -32,7 +34,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" aslimiter "dubbo.apache.org/dubbo-go/v3/filter/adaptivesvc/limiter" ) @@ -111,6 +112,17 @@ func (c *ProviderConfig) Init(rc *RootConfig) error { for k, v := range rc.Protocols { if v.Name == tripleConstant.TRIPLE { + // Auto create grpc based health check service. + healthService := NewServiceConfigBuilder(). + SetProtocolIDs(k). + SetNotRegister(true). + SetInterface(constant.HealthCheckServiceInterface). + Build() + if err := healthService.Init(rc); err != nil { + return err + } + c.Services[constant.HealthCheckServiceTypeName] = healthService + // Auto create reflection service configure only when provider with triple service is configured. tripleReflectionService := NewServiceConfigBuilder(). SetProtocolIDs(k). @@ -120,7 +132,9 @@ func (c *ProviderConfig) Init(rc *RootConfig) error { if err := tripleReflectionService.Init(rc); err != nil { return err } + // Maybe only register once, If setting this service, break from traversing Protocols. c.Services[constant.ReflectionServiceTypeName] = tripleReflectionService + break } } @@ -144,8 +158,9 @@ func (c *ProviderConfig) Load() { for registeredTypeName, service := range GetProviderServiceMap() { serviceConfig, ok := c.Services[registeredTypeName] if !ok { - if registeredTypeName == constant.ReflectionServiceTypeName { - // do not auto generate reflection server's configuration. + if registeredTypeName == constant.ReflectionServiceTypeName || + registeredTypeName == constant.HealthCheckServiceTypeName { + // do not auto generate reflection or health check server's configuration. continue } // service doesn't config in config file, create one with default diff --git a/config/provider_config_test.go b/config/provider_config_test.go index 1369b617e7..8f954941b5 100644 --- a/config/provider_config_test.go +++ b/config/provider_config_test.go @@ -42,7 +42,8 @@ func TestProviderConfigRootRegistry(t *testing.T) { assert.Nil(t, err) provider := rootConfig.Provider assert.NotNil(t, provider) - assert.Equal(t, 2, len(provider.Services)) + assert.NotNil(t, provider.Services["HelloService"]) + assert.NotNil(t, provider.Services["OrderService"]) assert.Equal(t, 2, len(provider.Services["HelloService"].RegistryIDs)) assert.Equal(t, 1, len(provider.Services["OrderService"].RegistryIDs)) diff --git a/config/reference_config.go b/config/reference_config.go index 4c443f7e43..d4dfe876ec 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -35,10 +35,10 @@ import ( "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/common/proxy" "dubbo.apache.org/dubbo-go/v3/config/generic" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" + "dubbo.apache.org/dubbo-go/v3/proxy" ) // ReferenceConfig is the configuration of service consumer @@ -96,6 +96,9 @@ func (rc *ReferenceConfig) Init(root *RootConfig) error { rc.Version = root.Application.Version } } + if rc.Filter == "" { + rc.Filter = root.Consumer.Filter + } if rc.Cluster == "" { rc.Cluster = "failover" } @@ -189,7 +192,7 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { invokers := make([]protocol.Invoker, len(rc.urls)) for i, u := range rc.urls { if u.Protocol == constant.ServiceRegistryProtocol { - invoker = extension.GetProtocol("registry").Refer(u) + invoker = extension.GetProtocol(constant.RegistryProtocol).Refer(u) } else { invoker = extension.GetProtocol(u.Protocol).Refer(u) } @@ -309,7 +312,7 @@ func (rc *ReferenceConfig) getURLMap() url.Values { if rc.Generic != "" { defaultReferenceFilter = constant.GenericFilterKey + "," + defaultReferenceFilter } - urlMap.Set(constant.ReferenceFilterKey, mergeValue(rc.rootConfig.Consumer.Filter, "", defaultReferenceFilter)) + urlMap.Set(constant.ReferenceFilterKey, mergeValue(rc.Filter, "", defaultReferenceFilter)) for _, v := range rc.Methods { urlMap.Set("methods."+v.Name+"."+constant.LoadbalanceKey, v.LoadBalance) diff --git a/config/reference_config_test.go b/config/reference_config_test.go index c8df59f884..01a3dab2d7 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -27,7 +27,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" ) //import ( diff --git a/config/registry_config.go b/config/registry_config.go index 5efba99623..c8cf359ea5 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -26,6 +26,8 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -33,7 +35,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/registry" ) diff --git a/config/root_config.go b/config/root_config.go index 7f3d1aa995..e069274c36 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -25,6 +25,8 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + "github.com/knadh/koanf" perrors "github.com/pkg/errors" @@ -36,7 +38,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" ) diff --git a/config/root_config_test.go b/config/root_config_test.go index 887991c58e..e49e1456ea 100644 --- a/config/root_config_test.go +++ b/config/root_config_test.go @@ -22,12 +22,13 @@ import ( ) import ( + "github.com/dubbogo/gost/encoding/yaml" + "github.com/stretchr/testify/assert" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/yaml" "dubbo.apache.org/dubbo-go/v3/config_center" ) diff --git a/config/service_config.go b/config/service_config.go index 9627f2b918..b0f75cf385 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -31,6 +31,7 @@ import ( import ( "github.com/creasty/defaults" + "github.com/dubbogo/gost/log/logger" gxnet "github.com/dubbogo/gost/net" perrors "github.com/pkg/errors" @@ -42,7 +43,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" ) @@ -109,6 +109,9 @@ func (s *ServiceConfig) Init(rc *RootConfig) error { } s.exported = atomic.NewBool(false) s.metadataType = rc.Application.MetadataType + if s.Filter == "" { + s.Filter = rc.Provider.Filter + } if s.Version == "" { s.Version = rc.Application.Version } diff --git a/config/service_config_test.go b/config/service_config_test.go index c3fa09d77c..5a0639f420 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -30,7 +30,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" ) type HelloService struct { diff --git a/config/testdata/config/center/apollo.yaml b/config/testdata/config/center/apollo.yaml deleted file mode 100644 index 0b10e9e793..0000000000 --- a/config/testdata/config/center/apollo.yaml +++ /dev/null @@ -1,8 +0,0 @@ -dubbo: - config-center: - address: apollo://106.54.227.205:8080 - cluster: dev - namespace: dubbogo.yaml - app-id: dubbo-go - params: - secret: 3a64cf5cd9ac4fcd94eb045de433689c \ No newline at end of file diff --git a/config/testdata/consumer_config_with_configcenter_apollo.yml b/config/testdata/consumer_config_with_configcenter_apollo.yml deleted file mode 100644 index 71a8b8c9df..0000000000 --- a/config/testdata/consumer_config_with_configcenter_apollo.yml +++ /dev/null @@ -1,24 +0,0 @@ -# use apollo config center for fetch config file -# default config file namespace is dubbo.properties -# consumer config file Ref:consumer_config.properties -# provider config file Ref:provider_config.properties -config_center: - protocol: apollo - address: 106.12.25.204:8080 - group: testApplication_yang - cluster: dev - # 'namespace' can be used for router rule , default value is dubbo.properties - # but if you want to change router rule config file ,just open this item -# namespace: governance.properties - # 'config_file' is not necessary ,default : dubbo.properties - # but if you want to change config file ,just open this item -# config_file: mockDubbog.properties - -# application config required -application: - organization: "ikurento.com" - name: "BDTService" - module: "dubbogo user-info server" - version: "0.0.1" - owner: "ZX" - environment: "dev" \ No newline at end of file diff --git a/config_center/apollo/factory.go b/config_center/apollo/factory.go deleted file mode 100644 index 536c22feb3..0000000000 --- a/config_center/apollo/factory.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 apollo - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config_center" - "dubbo.apache.org/dubbo-go/v3/config_center/parser" -) - -func init() { - extension.SetConfigCenterFactory("apollo", createDynamicConfigurationFactory) -} - -func createDynamicConfigurationFactory() config_center.DynamicConfigurationFactory { - return &apolloConfigurationFactory{} -} - -type apolloConfigurationFactory struct{} - -// GetDynamicConfiguration gets the dynamic configuration -func (f *apolloConfigurationFactory) GetDynamicConfiguration(url *common.URL) (config_center.DynamicConfiguration, error) { - dynamicConfiguration, err := newApolloConfiguration(url) - if err != nil { - return nil, err - } - dynamicConfiguration.SetParser(&parser.DefaultConfigurationParser{}) - return dynamicConfiguration, err -} diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go deleted file mode 100644 index f6f64e47ea..0000000000 --- a/config_center/apollo/impl.go +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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 apollo - -import ( - "fmt" - "regexp" - "strings" - "sync" -) - -import ( - gxset "github.com/dubbogo/gost/container/set" - - perrors "github.com/pkg/errors" - - "github.com/zouyx/agollo/v3" - "github.com/zouyx/agollo/v3/env/config" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" - cc "dubbo.apache.org/dubbo-go/v3/config_center" - "dubbo.apache.org/dubbo-go/v3/config_center/parser" -) - -const ( - apolloProtocolPrefix = "http://" -) - -type apolloConfiguration struct { - cc.BaseDynamicConfiguration - url *common.URL - - listeners sync.Map - appConf *config.AppConfig - parser parser.ConfigurationParser -} - -func newApolloConfiguration(url *common.URL) (*apolloConfiguration, error) { - c := &apolloConfiguration{ - url: url, - } - c.appConf = &config.AppConfig{ - AppID: url.GetParam(constant.ConfigAppIDKey, ""), - Cluster: url.GetParam(constant.ConfigClusterKey, ""), - NamespaceName: url.GetParam(constant.ConfigNamespaceKey, cc.DefaultGroup), - IP: c.getAddressWithProtocolPrefix(url), - Secret: url.GetParam(constant.ConfigSecretKey, ""), - IsBackupConfig: url.GetParamBool(constant.ConfigBackupConfigKey, true), - BackupConfigPath: url.GetParam(constant.ConfigBackupConfigPathKey, ""), - } - logger.Infof("[Apollo ConfigCenter] New Apollo ConfigCenter with Configuration: %+v, url = %+v", c.appConf, c.url) - agollo.InitCustomConfig(func() (*config.AppConfig, error) { - return c.appConf, nil - }) - return c, agollo.Start() -} - -func (c *apolloConfiguration) AddListener(key string, listener cc.ConfigurationListener, opts ...cc.Option) { - k := &cc.Options{} - for _, opt := range opts { - opt(k) - } - - key = k.Group + key - l, _ := c.listeners.LoadOrStore(key, newApolloListener()) - l.(*apolloListener).AddListener(listener) -} - -func (c *apolloConfiguration) RemoveListener(key string, listener cc.ConfigurationListener, opts ...cc.Option) { - k := &cc.Options{} - for _, opt := range opts { - opt(k) - } - - key = k.Group + key - l, ok := c.listeners.Load(key) - if ok { - l.(*apolloListener).RemoveListener(listener) - } -} - -func (c *apolloConfiguration) GetInternalProperty(key string, opts ...cc.Option) (string, error) { - newConfig := agollo.GetConfig(c.appConf.NamespaceName) - if newConfig == nil { - return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) - } - return newConfig.GetStringValue(key, ""), nil -} - -func (c *apolloConfiguration) GetRule(key string, opts ...cc.Option) (string, error) { - return c.GetInternalProperty(key, opts...) -} - -// PublishConfig will publish the config with the (key, group, value) pair -func (c *apolloConfiguration) PublishConfig(string, string, string) error { - return perrors.New("unsupport operation") -} - -// GetConfigKeysByGroup will return all keys with the group -func (c *apolloConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet, error) { - return nil, perrors.New("unsupport operation") -} - -func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (string, error) { - /** - * when group is not null, we are getting startup configs(config file) from ShutdownConfig Center, for example: - * key=dubbo.propertie - */ - if key == "" { - key = c.appConf.NamespaceName - } - tmpConfig := agollo.GetConfig(key) - if tmpConfig == nil { - return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) - } - - content := tmpConfig.GetContent() - b := []byte(content) - if len(b) == 0 { - return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) - } - - content = string(b[8:]) //remove defalut content= prefix - return content, nil -} - -func (c *apolloConfiguration) getAddressWithProtocolPrefix(url *common.URL) string { - address := url.Location - converted := address - if len(address) != 0 { - addr := regexp.MustCompile(`\s+`).ReplaceAllString(address, "") - parts := strings.Split(addr, ",") - addrs := make([]string, 0) - for _, part := range parts { - addr := part - if !strings.HasPrefix(part, apolloProtocolPrefix) { - addr = apolloProtocolPrefix + part - } - addrs = append(addrs, addr) - } - converted = strings.Join(addrs, ",") - } - return converted -} - -func (c *apolloConfiguration) Parser() parser.ConfigurationParser { - return c.parser -} - -func (c *apolloConfiguration) SetParser(p parser.ConfigurationParser) { - c.parser = p -} diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go deleted file mode 100644 index 70b03af114..0000000000 --- a/config_center/apollo/impl_test.go +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 apollo - -import ( - "encoding/json" - "fmt" - "net/http" - "net/http/httptest" - "strings" - "sync" - "testing" -) - -import ( - "github.com/knadh/koanf" - "github.com/knadh/koanf/parsers/yaml" - "github.com/knadh/koanf/providers/rawbytes" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config_center" - "dubbo.apache.org/dubbo-go/v3/config_center/parser" - "dubbo.apache.org/dubbo-go/v3/remoting" -) - -const ( - mockAppId = "testApplication_yang" - mockCluster = "dev" - mockNamespace = "mockDubbogo.yaml" - mockNotifyRes = `[{ - "namespaceName": "mockDubbogo.yaml", - "notificationId": 53050, - "messages": { - "details": { - "testApplication_yang+default+mockDubbogo": 53050 - } - } -}]` - mockServiceConfigRes = `[{ - "appName": "APOLLO-CONFIGSERVICE", - "instanceId": "instance-300408ep:apollo-configservice:8080", - "homepageUrl": "http://localhost:8080" -}]` -) - -var mockConfigRes = `{ - "appId": "testApplication_yang", - "cluster": "default", - "namespaceName": "mockDubbogo.yaml", - "configurations":{ - "content":"dubbo:\n application:\n name: \"demo-server\"\n version: \"2.0\"\n" - }, - "releaseKey": "20191104105242-0f13805d89f834a4" -}` - -func initApollo() *httptest.Server { - handlerMap := make(map[string]func(http.ResponseWriter, *http.Request), 1) - handlerMap[mockNamespace] = configResponse - - return runMockConfigServer(handlerMap, notifyResponse) -} - -func configResponse(rw http.ResponseWriter, _ *http.Request) { - result := mockConfigRes - fmt.Fprintf(rw, "%s", result) -} - -func notifyResponse(rw http.ResponseWriter, req *http.Request) { - result := mockNotifyRes - fmt.Fprintf(rw, "%s", result) -} - -func serviceConfigResponse(rw http.ResponseWriter, _ *http.Request) { - result := mockServiceConfigRes - fmt.Fprintf(rw, "%s", result) -} - -// run mock config server -func runMockConfigServer(handlerMap map[string]func(http.ResponseWriter, *http.Request), - notifyHandler func(http.ResponseWriter, *http.Request)) *httptest.Server { - uriHandlerMap := make(map[string]func(http.ResponseWriter, *http.Request)) - for namespace, handler := range handlerMap { - uri := fmt.Sprintf("/configs/%s/%s/%s", mockAppId, mockCluster, namespace) - uriHandlerMap[uri] = handler - } - uriHandlerMap["/notifications/v2"] = notifyHandler - uriHandlerMap["/services/config"] = serviceConfigResponse - - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - uri := r.RequestURI - for path, handler := range uriHandlerMap { - if strings.HasPrefix(uri, path) { - handler(w, r) - break - } - } - })) - - return ts -} - -func TestGetConfig(t *testing.T) { - configuration := initMockApollo(t) - configs, err := configuration.GetProperties(mockNamespace, config_center.WithGroup("dubbo")) - assert.NoError(t, err) - koan := koanf.New(".") - err = koan.Load(rawbytes.Provider([]byte(configs)), yaml.Parser()) - assert.NoError(t, err) - rc := &config.RootConfig{} - err = koan.UnmarshalWithConf(rc.Prefix(), rc, koanf.UnmarshalConf{Tag: "yaml"}) - assert.NoError(t, err) - - assert.Equal(t, "demo-server", rc.Application.Name) -} - -func TestGetConfigItem(t *testing.T) { - configuration := initMockApollo(t) - configs, err := configuration.GetInternalProperty("content") - assert.NoError(t, err) - configuration.SetParser(&parser.DefaultConfigurationParser{}) - assert.NoError(t, err) - type MockRes struct { - Configurations struct { - Content string - } - } - mockRes := &MockRes{} - err = json.Unmarshal([]byte(mockConfigRes), mockRes) - assert.NoError(t, err) - assert.Equal(t, mockRes.Configurations.Content, configs) -} - -func initMockApollo(t *testing.T) *apolloConfiguration { - c := &config.RootConfig{ConfigCenter: &config.CenterConfig{ - Protocol: "apollo", - Address: "106.12.25.204:8080", - AppID: "testApplication_yang", - Cluster: "dev", - Namespace: "mockDubbogo.yaml", - }} - apollo := initApollo() - apolloUrl := strings.ReplaceAll(apollo.URL, "http", "apollo") - url, err := common.NewURL(apolloUrl, common.WithParams(c.ConfigCenter.GetUrlMap())) - assert.NoError(t, err) - configuration, err := newApolloConfiguration(url) - assert.NoError(t, err) - return configuration -} - -func TestListener(t *testing.T) { - listener := &apolloDataListener{} - listener.wg.Add(2) - apollo := initMockApollo(t) - mockConfigRes = `{ - "appId": "testApplication_yang", - "cluster": "default", - "namespaceName": "mockDubbogo.yaml", - "configurations": { - "registries.hangzhouzk.username": "11111" - }, - "releaseKey": "20191104105242-0f13805d89f834a4" -}` - // test add - apollo.AddListener(mockNamespace, listener) - listener.wg.Wait() - assert.Equal(t, "mockDubbogo.yaml", listener.event) - assert.Greater(t, listener.count, 0) - - // test remove - apollo.RemoveListener(mockNamespace, listener) - listenerCount := 0 - apollo.listeners.Range(func(_, value interface{}) bool { - apolloListener := value.(*apolloListener) - for e := range apolloListener.listeners { - t.Logf("listener:%v", e) - listenerCount++ - } - return true - }) - assert.Equal(t, listenerCount, 0) -} - -type apolloDataListener struct { - wg sync.WaitGroup - count int - event string -} - -func (l *apolloDataListener) Process(configType *config_center.ConfigChangeEvent) { - if configType.ConfigType != remoting.EventTypeUpdate { - return - } - l.wg.Done() - l.count++ - l.event = configType.Key -} diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go deleted file mode 100644 index 9080b73877..0000000000 --- a/config_center/apollo/listener.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 apollo - -import ( - "github.com/zouyx/agollo/v3" - "github.com/zouyx/agollo/v3/storage" - - "gopkg.in/yaml.v2" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config_center" - "dubbo.apache.org/dubbo-go/v3/remoting" -) - -type apolloListener struct { - listeners map[config_center.ConfigurationListener]struct{} -} - -// nolint -func newApolloListener() *apolloListener { - return &apolloListener{ - listeners: make(map[config_center.ConfigurationListener]struct{}), - } -} - -// OnChange process each listener -func (a *apolloListener) OnChange(changeEvent *storage.ChangeEvent) { -} - -// OnNewestChange process each listener by all changes -func (a *apolloListener) OnNewestChange(changeEvent *storage.FullChangeEvent) { - b, err := yaml.Marshal(changeEvent.Changes) - if err != nil { - logger.Errorf("apollo onNewestChange err %+v", - err) - return - } - content := string(b) - for listener := range a.listeners { - listener.Process(&config_center.ConfigChangeEvent{ - ConfigType: remoting.EventTypeUpdate, - Key: changeEvent.Namespace, - Value: content, - }) - } -} - -// AddListener adds a listener for apollo -func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { - if _, ok := a.listeners[l]; !ok { - a.listeners[l] = struct{}{} - agollo.AddChangeListener(a) - } -} - -// RemoveListener removes listeners of apollo -func (a *apolloListener) RemoveListener(l config_center.ConfigurationListener) { - delete(a.listeners, l) -} diff --git a/config_center/apollo/mockDubbogo.yaml.json b/config_center/apollo/mockDubbogo.yaml.json deleted file mode 100644 index 4131bededc..0000000000 --- a/config_center/apollo/mockDubbogo.yaml.json +++ /dev/null @@ -1 +0,0 @@ -{"appId":"testApplication_yang","cluster":"default","namespaceName":"mockDubbogo.yaml","releaseKey":"20191104105242-0f13805d89f834a4","configurations":{"registries.hangzhouzk.username":"11111"}} diff --git a/config_center/file/listener.go b/config_center/file/listener.go index 820768be20..c68643532e 100644 --- a/config_center/file/listener.go +++ b/config_center/file/listener.go @@ -23,12 +23,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/fsnotify/fsnotify" ) import ( "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go index 08ba373cb0..52850115b1 100644 --- a/config_center/nacos/client.go +++ b/config_center/nacos/client.go @@ -24,12 +24,12 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting/nacos" ) diff --git a/config_center/nacos/facade.go b/config_center/nacos/facade.go index 6141e1ea46..7b8ce8c0c6 100644 --- a/config_center/nacos/facade.go +++ b/config_center/nacos/facade.go @@ -23,11 +23,11 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) type nacosClientFacade interface { diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index f7e3f1f07b..1a4ffa8bbc 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -25,6 +25,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" constant2 "github.com/nacos-group/nacos-sdk-go/common/constant" "github.com/nacos-group/nacos-sdk-go/vo" @@ -35,7 +36,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/parser" ) diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go index a4cf589e42..ab335db648 100644 --- a/config_center/nacos/listener.go +++ b/config_center/nacos/listener.go @@ -22,13 +22,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + constant2 "github.com/nacos-group/nacos-sdk-go/common/constant" "github.com/nacos-group/nacos-sdk-go/vo" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go index 47c2410f52..1f4b96083a 100644 --- a/config_center/parser/configuration_parser.go +++ b/config_center/parser/configuration_parser.go @@ -23,6 +23,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/magiconair/properties" perrors "github.com/pkg/errors" @@ -33,7 +35,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) const ( diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index 730b882177..538058cf1f 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -29,6 +29,7 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -36,7 +37,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/parser" diff --git a/filter/accesslog/filter.go b/filter/accesslog/filter.go index 94a7a4c90a..91b3898b1c 100644 --- a/filter/accesslog/filter.go +++ b/filter/accesslog/filter.go @@ -27,10 +27,13 @@ import ( "time" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/active/filter.go b/filter/active/filter.go index 8ee781b822..78b8b62f25 100644 --- a/filter/active/filter.go +++ b/filter/active/filter.go @@ -23,10 +23,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" invocation2 "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/filter/adaptivesvc/filter.go b/filter/adaptivesvc/filter.go index 2af36db11b..11c5015aac 100644 --- a/filter/adaptivesvc/filter.go +++ b/filter/adaptivesvc/filter.go @@ -26,13 +26,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/filter/adaptivesvc/limiter" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/filter/adaptivesvc/limiter/hill_climbing.go b/filter/adaptivesvc/limiter/hill_climbing.go index 296d6e0d4a..3ce16ee0a3 100644 --- a/filter/adaptivesvc/limiter/hill_climbing.go +++ b/filter/adaptivesvc/limiter/hill_climbing.go @@ -130,7 +130,7 @@ func NewHillClimbingUpdater(limiter *HillClimbing) *HillClimbingUpdater { seq: limiter.seq.Add(1) - 1, } VerboseDebugf("[NewHillClimbingUpdater] A new request arrived, seq: %d, inflight: %d, time: %s.", - u.seq, inflight, u.startTime.String()) + u.seq, inflight, u.startTime) return u } diff --git a/filter/adaptivesvc/limiter/utils.go b/filter/adaptivesvc/limiter/utils.go index 18aa685805..f1fc3460b9 100644 --- a/filter/adaptivesvc/limiter/utils.go +++ b/filter/adaptivesvc/limiter/utils.go @@ -22,7 +22,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + "github.com/dubbogo/gost/log/logger" ) func VerboseDebugf(msg string, args ...interface{}) { diff --git a/filter/auth/provider_auth_filter.go b/filter/auth/provider_auth_filter.go index 332ff43efa..bf462d29be 100644 --- a/filter/auth/provider_auth_filter.go +++ b/filter/auth/provider_auth_filter.go @@ -22,10 +22,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/auth/sign_util.go b/filter/auth/sign_util.go index 1f5afe39f9..97cd0a7a1d 100644 --- a/filter/auth/sign_util.go +++ b/filter/auth/sign_util.go @@ -27,7 +27,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + "github.com/dubbogo/gost/log/logger" ) // Sign gets a signature string with given bytes diff --git a/filter/exec_limit/filter.go b/filter/exec_limit/filter.go index ed919a3746..8d0967f2c9 100644 --- a/filter/exec_limit/filter.go +++ b/filter/exec_limit/filter.go @@ -50,13 +50,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/modern-go/concurrent" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" _ "dubbo.apache.org/dubbo-go/v3/filter/handler" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/filter/generic/filter.go b/filter/generic/filter.go index 6733d103a2..d385494c99 100644 --- a/filter/generic/filter.go +++ b/filter/generic/filter.go @@ -25,12 +25,13 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + + "github.com/dubbogo/gost/log/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" invocation2 "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/filter/generic/generalizer/gson.go b/filter/generic/generalizer/gson.go index 7896071db9..1a2102e681 100644 --- a/filter/generic/generalizer/gson.go +++ b/filter/generic/generalizer/gson.go @@ -26,11 +26,12 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/hessian2" ) diff --git a/filter/generic/generalizer/map.go b/filter/generic/generalizer/map.go index 5aa573c372..bbf55955b7 100644 --- a/filter/generic/generalizer/map.go +++ b/filter/generic/generalizer/map.go @@ -27,13 +27,14 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + "github.com/mitchellh/mapstructure" perrors "github.com/pkg/errors" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/hessian2" ) diff --git a/filter/generic/service_filter.go b/filter/generic/service_filter.go index b8a09893b2..c9a97c3c51 100644 --- a/filter/generic/service_filter.go +++ b/filter/generic/service_filter.go @@ -25,6 +25,8 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -32,7 +34,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" invocation2 "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/filter/generic/util.go b/filter/generic/util.go index 8bd05b92ad..f6e5fc1aa3 100644 --- a/filter/generic/util.go +++ b/filter/generic/util.go @@ -21,9 +21,12 @@ import ( "strings" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter/generic/generalizer" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/graceful_shutdown/consumer_filter.go b/filter/graceful_shutdown/consumer_filter.go index f49c66100b..6ff12bf83d 100644 --- a/filter/graceful_shutdown/consumer_filter.go +++ b/filter/graceful_shutdown/consumer_filter.go @@ -22,10 +22,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/filter/graceful_shutdown/provider_filter.go b/filter/graceful_shutdown/provider_filter.go index d69aeb49b0..b9ad3a9650 100644 --- a/filter/graceful_shutdown/provider_filter.go +++ b/filter/graceful_shutdown/provider_filter.go @@ -23,10 +23,13 @@ import ( "time" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/filter/handler/rejected_execution_handler_only_log.go b/filter/handler/rejected_execution_handler_only_log.go index ac541d3fd9..445493b9ad 100644 --- a/filter/handler/rejected_execution_handler_only_log.go +++ b/filter/handler/rejected_execution_handler_only_log.go @@ -21,11 +21,14 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/hystrix/filter.go b/filter/hystrix/filter.go index df8203e61f..db102ab70c 100644 --- a/filter/hystrix/filter.go +++ b/filter/hystrix/filter.go @@ -29,6 +29,8 @@ import ( import ( "github.com/afex/hystrix-go/hystrix" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" "gopkg.in/yaml.v2" @@ -37,7 +39,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/filter/seata/filter.go b/filter/seata/filter.go index 8d4757123d..93d6baf260 100644 --- a/filter/seata/filter.go +++ b/filter/seata/filter.go @@ -24,10 +24,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/sentinel/filter.go b/filter/sentinel/filter.go index 06f6771876..fdedf8dba2 100644 --- a/filter/sentinel/filter.go +++ b/filter/sentinel/filter.go @@ -32,13 +32,14 @@ import ( sentinel "github.com/alibaba/sentinel-golang/api" "github.com/alibaba/sentinel-golang/core/base" "github.com/alibaba/sentinel-golang/logging" + + "github.com/dubbogo/gost/log/logger" ) import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/tps/filter.go b/filter/tps/filter.go index ff1531f5d5..1cc822bb65 100644 --- a/filter/tps/filter.go +++ b/filter/tps/filter.go @@ -36,10 +36,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" _ "dubbo.apache.org/dubbo-go/v3/filter/handler" _ "dubbo.apache.org/dubbo-go/v3/filter/tps/limiter" diff --git a/filter/tps/limiter/method_service.go b/filter/tps/limiter/method_service.go index 8925e042dc..09b5918e06 100644 --- a/filter/tps/limiter/method_service.go +++ b/filter/tps/limiter/method_service.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/modern-go/concurrent" ) @@ -31,7 +33,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/filter/xds/cb/filter.go b/filter/xds/cb/filter.go index 50631bd809..841cc1493f 100644 --- a/filter/xds/cb/filter.go +++ b/filter/xds/cb/filter.go @@ -21,11 +21,14 @@ import ( "context" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/remoting/xds" diff --git a/go.mod b/go.mod index e4a4cf1ae0..0d5f2844cb 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( contrib.go.opencensus.io/exporter/prometheus v0.4.1 - github.com/RoaringBitmap/roaring v1.0.0 + github.com/RoaringBitmap/roaring v1.2.0 github.com/Workiva/go-datastructures v1.0.52 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alibaba/sentinel-golang v1.0.4 @@ -15,10 +15,10 @@ require ( github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 - github.com/dubbogo/gost v1.11.25 + github.com/dubbogo/gost v1.12.5 github.com/dubbogo/grpc-go v1.42.9 github.com/dubbogo/triple v1.1.8 - github.com/emicklei/go-restful/v3 v3.7.4 + github.com/emicklei/go-restful/v3 v3.8.0 github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 github.com/fsnotify/fsnotify v1.5.4 github.com/go-co-op/gocron v1.9.0 @@ -29,9 +29,9 @@ require ( github.com/google/go-cmp v0.5.8 github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 // indirect github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 - github.com/hashicorp/vault/sdk v0.3.0 + github.com/hashicorp/vault/sdk v0.5.2 github.com/jinzhu/copier v0.3.5 - github.com/knadh/koanf v1.4.1 + github.com/knadh/koanf v1.4.2 github.com/magiconair/properties v1.8.6 github.com/mitchellh/mapstructure v1.5.0 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd @@ -42,9 +42,7 @@ require ( github.com/polarismesh/polaris-go v1.1.0 github.com/prometheus/client_golang v1.12.2 github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b - github.com/spf13/afero v1.2.2 // indirect - github.com/stretchr/testify v1.7.1 - github.com/zouyx/agollo/v3 v3.4.5 + github.com/stretchr/testify v1.8.0 go.etcd.io/etcd/api/v3 v3.5.4 go.etcd.io/etcd/client/v3 v3.5.4 go.opentelemetry.io/otel v1.7.0 @@ -52,7 +50,7 @@ require ( go.uber.org/atomic v1.9.0 go.uber.org/zap v1.21.0 google.golang.org/genproto v0.0.0-20211104193956-4c6863e31247 - google.golang.org/grpc v1.46.2 + google.golang.org/grpc v1.47.0 google.golang.org/protobuf v1.28.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index a0a33e3797..c75570273b 100644 --- a/go.sum +++ b/go.sum @@ -43,11 +43,10 @@ github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/RoaringBitmap/roaring v1.0.0 h1:lWiFitikIbD/wEcSEetpVtBOP7djMpnfR4kVZ4W9wW8= -github.com/RoaringBitmap/roaring v1.0.0/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= +github.com/RoaringBitmap/roaring v1.2.0 h1:qayex3YgtOmzev8slia4A0jPGsn2o2bnqKDcRpyRUiI= +github.com/RoaringBitmap/roaring v1.2.0/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= @@ -174,8 +173,8 @@ github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5/go.mod h1:f github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.11.18/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.23/go.mod h1:PhJ8+qZJx+Txjx1KthNPuVkCvUca0jRLgKWj/noGgeI= -github.com/dubbogo/gost v1.11.25 h1:jFxE+YPh+ajrkHz7AxaaqYNMdKMDf/yfI1D+ZFoxfW0= -github.com/dubbogo/gost v1.11.25/go.mod h1:iovrPhv0hyakhQGVr4jwiECBL9HXNuBY4VV3HWK5pM0= +github.com/dubbogo/gost v1.12.5 h1:vpqQOAh5d1w/Qc+cvJmyiWRkwHFQPmZfgGwCBjuesBY= +github.com/dubbogo/gost v1.12.5/go.mod h1:f0bcP1xpBUdDgiNjNYKF6F3qlA+RFKs0k980FhoEn/g= github.com/dubbogo/grpc-go v1.42.9 h1:nTuglkH9rTJzQfardU4b0OJ0Imd2169dMNLBTNhTdlc= github.com/dubbogo/grpc-go v1.42.9/go.mod h1:F1T9hnUvYGW4JLK1QNriavpOkhusU677ovPzLkk6zHM= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= @@ -190,8 +189,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/emicklei/go-restful/v3 v3.7.4 h1:PVGUqKvvMzQYiO89TdXrH9EMks+okTaRIMQ3jgMdZ30= -github.com/emicklei/go-restful/v3 v3.7.4/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.8.0 h1:eCZ8ulSerjdAiaNpF7GxXIE7ZCMo1moN1qX+S609eVw= +github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -249,8 +248,9 @@ github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -409,8 +409,10 @@ github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR3 github.com/hashicorp/go-secure-stdlib/base62 v0.1.1/go.mod h1:EdWO6czbmthiwZ3/PUsDV+UD1D5IRU4ActiaWGwt0Yw= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= +github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= github.com/hashicorp/go-secure-stdlib/password v0.1.1/go.mod h1:9hH302QllNwu1o2TGYtSk8I8kTAN0ca1EHpwhm5Mmzo= github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U= +github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.1/go.mod h1:l8slYwnJA26yBz+ErHpp2IRCLr0vuOMGBORIz4rRiAs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= @@ -432,8 +434,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.3.0 h1:kR3dpxNkhh/wr6ycaJYqp6AFT/i2xaftbfnwZduTKEY= -github.com/hashicorp/vault/sdk v0.3.0/go.mod h1:aZ3fNuL5VNydQk8GcLJ2TV8YCRVvyaakYkhZRoVuhj0= +github.com/hashicorp/vault/sdk v0.5.2 h1:Lub3cuwra6ifGmVYqX0x2pehWmUZl3zTElIjnyvBe2M= +github.com/hashicorp/vault/sdk v0.5.2/go.mod h1:DoGraE9kKGNcVgPmTuX357Fm6WAx1Okvde8Vp3dPDoU= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -481,8 +483,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/knadh/koanf v1.4.1 h1:Z0VGW/uo8NJmjd+L1Dc3S5frq6c62w5xQ9Yf4Mg3wFQ= -github.com/knadh/koanf v1.4.1/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= +github.com/knadh/koanf v1.4.2 h1:2itp+cdC6miId4pO4Jw7c/3eiYD26Z/Sz3ATJMwHxIs= +github.com/knadh/koanf v1.4.2/go.mod h1:4NCo0q4pmU398vF9vq2jStF9MWQZ8JEDcDMHlDCr4h0= github.com/koding/multiconfig v0.0.0-20171124222453-69c27309b2d7/go.mod h1:Y2SaZf2Rzd0pXkLVhLlCiAXFCLSXAIbTKDivVgff/AM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -503,6 +505,8 @@ github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= @@ -538,7 +542,6 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -611,6 +614,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/polarismesh/polaris-go v1.1.0 h1:nFvn3q3XaVFhzF7pBnIySrN0ZZBwvbbYXC5r2DpsQN0= github.com/polarismesh/polaris-go v1.1.0/go.mod h1:tquawfjEKp1W3ffNJQSzhfditjjoZ7tvhOCElN7Efzs= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -677,8 +682,9 @@ github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrY github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.21.6 h1:vU7jrp1Ic/2sHB7w6UNs7MIkn7ebVtTb5D9j45o9VYE= github.com/shirou/gopsutil/v3 v3.21.6/go.mod h1:JfVbDpIBLVzT8oKbvMg9P3wEIMDDpVn+LwHTKj0ST88= +github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks= +github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -698,44 +704,41 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= -github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= -github.com/tklauser/go-sysconf v0.3.6 h1:oc1sJWvKkmvIxhDHeKWvZS4f6AW+YcoguSfRF2/Hmo4= github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= -github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= +github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= +github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= +github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -760,8 +763,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ= -github.com/zouyx/agollo/v3 v3.4.5/go.mod h1:LJr3kDmm23QSW+F1Ol4TMHDa7HvJvscMdVxJ2IpUTVc= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= @@ -963,6 +966,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -991,6 +995,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1004,9 +1009,12 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1186,8 +1194,8 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= +google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1235,8 +1243,10 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/imports/imports.go b/imports/imports.go index 3ac1d74abc..f818e4322c 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -32,8 +32,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/p2c" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/roundrobin" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" + _ "dubbo.apache.org/dubbo-go/v3/cluster/router/meshrouter" _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" _ "dubbo.apache.org/dubbo-go/v3/filter/accesslog" @@ -64,10 +63,12 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" + _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/health" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/reflection" _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc" _ "dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc" _ "dubbo.apache.org/dubbo-go/v3/protocol/rest" + _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" _ "dubbo.apache.org/dubbo-go/v3/registry/etcdv3" _ "dubbo.apache.org/dubbo-go/v3/registry/nacos" _ "dubbo.apache.org/dubbo-go/v3/registry/polaris" diff --git a/metadata/mapping/metadata/service_name_mapping.go b/metadata/mapping/metadata/service_name_mapping.go index 848b2d3c47..ae934ae481 100644 --- a/metadata/mapping/metadata/service_name_mapping.go +++ b/metadata/mapping/metadata/service_name_mapping.go @@ -23,6 +23,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -31,7 +32,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go index d1e357129d..70a12ac226 100644 --- a/metadata/report/delegate/delegate_report.go +++ b/metadata/report/delegate/delegate_report.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/go-co-op/gocron" perrors "github.com/pkg/errors" @@ -35,7 +37,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" diff --git a/metadata/report/delegate/delegate_report_test.go b/metadata/report/delegate/delegate_report_test.go index 343c8ab92b..060cf161b9 100644 --- a/metadata/report/delegate/delegate_report_test.go +++ b/metadata/report/delegate/delegate_report_test.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/stretchr/testify/assert" "go.uber.org/atomic" @@ -32,7 +34,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go index fadfb01506..6d066b17ff 100644 --- a/metadata/report/etcd/report.go +++ b/metadata/report/etcd/report.go @@ -25,6 +25,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -33,7 +34,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" "dubbo.apache.org/dubbo-go/v3/metadata/report" "dubbo.apache.org/dubbo-go/v3/metadata/report/factory" diff --git a/metadata/report/nacos/report.go b/metadata/report/nacos/report.go index 3f20fc3634..655b577040 100644 --- a/metadata/report/nacos/report.go +++ b/metadata/report/nacos/report.go @@ -26,6 +26,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" "github.com/nacos-group/nacos-sdk-go/vo" @@ -36,7 +37,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" "dubbo.apache.org/dubbo-go/v3/metadata/report" "dubbo.apache.org/dubbo-go/v3/metadata/report/factory" diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go index f8594afb77..e93c9153a9 100644 --- a/metadata/report/zookeeper/report.go +++ b/metadata/report/zookeeper/report.go @@ -27,13 +27,13 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" ) import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" "dubbo.apache.org/dubbo-go/v3/metadata/report" "dubbo.apache.org/dubbo-go/v3/metadata/report/factory" diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index a074d6ecc0..b8e17422ec 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -21,11 +21,14 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/metadata" "dubbo.apache.org/dubbo-go/v3/metadata/service" diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index da42bf4165..aeb260cfde 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -27,12 +27,12 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" + _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/remoting/getty" ) diff --git a/metadata/service/local/metadata_service_proxy_factory.go b/metadata/service/local/metadata_service_proxy_factory.go index ee9c2921ff..417cc4cf8d 100644 --- a/metadata/service/local/metadata_service_proxy_factory.go +++ b/metadata/service/local/metadata_service_proxy_factory.go @@ -22,11 +22,14 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/registry" ) diff --git a/metadata/service/local/service.go b/metadata/service/local/service.go index 6761277ad5..2b2e6ac88a 100644 --- a/metadata/service/local/service.go +++ b/metadata/service/local/service.go @@ -24,13 +24,14 @@ import ( import ( "github.com/Workiva/go-datastructures/slice/skip" + + "github.com/dubbogo/gost/log/logger" ) import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/service" diff --git a/metadata/service/local/service_proxy.go b/metadata/service/local/service_proxy.go index b5f95457a5..711058d8e8 100644 --- a/metadata/service/local/service_proxy.go +++ b/metadata/service/local/service_proxy.go @@ -22,10 +22,13 @@ import ( "reflect" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go index 0c8ee8f004..aaf6aae629 100644 --- a/metadata/service/remote/service.go +++ b/metadata/service/remote/service.go @@ -22,6 +22,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "go.uber.org/atomic" ) @@ -29,7 +31,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" "dubbo.apache.org/dubbo-go/v3/metadata/report/delegate" diff --git a/metadata/service/remote/service_test.go b/metadata/service/remote/service_test.go index 0ea7121c8d..ae1eeea3ef 100644 --- a/metadata/service/remote/service_test.go +++ b/metadata/service/remote/service_test.go @@ -24,6 +24,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/log/logger" "github.com/stretchr/testify/assert" ) @@ -31,7 +32,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index cee640ebd0..231a2c8832 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -29,6 +29,8 @@ import ( import ( ocprom "contrib.go.opencensus.io/exporter/prometheus" + "github.com/dubbogo/gost/log/logger" + "github.com/prometheus/client_golang/prometheus" prom "github.com/prometheus/client_golang/prometheus" ) @@ -37,7 +39,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metrics" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go index 5f287c3159..92f7132bf8 100644 --- a/protocol/dubbo/dubbo_codec.go +++ b/protocol/dubbo/dubbo_codec.go @@ -26,12 +26,13 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl" invct "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/protocol/dubbo/dubbo_exporter.go b/protocol/dubbo/dubbo_exporter.go index 655c28e4d4..1f4008438e 100644 --- a/protocol/dubbo/dubbo_exporter.go +++ b/protocol/dubbo/dubbo_exporter.go @@ -21,10 +21,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index bbf3a25ea1..df16807eed 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -26,13 +26,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/opentracing/opentracing-go" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" invocation_impl "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 8d12bba69e..e7a3f28534 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -39,7 +39,7 @@ package dubbo //import ( // "dubbo.apache.org/dubbo-go/v3/common" // "dubbo.apache.org/dubbo-go/v3/common/constant" -// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" // "dubbo.apache.org/dubbo-go/v3/protocol" // "dubbo.apache.org/dubbo-go/v3/protocol/invocation" // "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 6aa633b018..573afa9294 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/opentracing/opentracing-go" ) @@ -32,7 +34,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index d6d3b376bf..3ccbcd1582 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -28,8 +28,8 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/remoting/getty" ) diff --git a/protocol/dubbo/hessian2/hessian_request.go b/protocol/dubbo/hessian2/hessian_request.go index 11c407a25e..608b03fdc5 100644 --- a/protocol/dubbo/hessian2/hessian_request.go +++ b/protocol/dubbo/hessian2/hessian_request.go @@ -27,11 +27,9 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" - perrors "github.com/pkg/errors" -) + "github.com/dubbogo/gost/log/logger" -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + perrors "github.com/pkg/errors" ) func getArgType(v interface{}) string { diff --git a/protocol/dubbo/hessian2/hessian_response.go b/protocol/dubbo/hessian2/hessian_response.go index 51bc725809..2dc5f376f0 100644 --- a/protocol/dubbo/hessian2/hessian_response.go +++ b/protocol/dubbo/hessian2/hessian_response.go @@ -29,11 +29,9 @@ import ( hessian "github.com/apache/dubbo-go-hessian2" "github.com/apache/dubbo-go-hessian2/java_exception" - perrors "github.com/pkg/errors" -) + "github.com/dubbogo/gost/log/logger" -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + perrors "github.com/pkg/errors" ) // DubboResponse dubbo response diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go index 46e8dadba7..f629f9133c 100644 --- a/protocol/dubbo/impl/codec.go +++ b/protocol/dubbo/impl/codec.go @@ -25,12 +25,13 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/protocol/dubbo/impl/hessian.go b/protocol/dubbo/impl/hessian.go index 79e531abf1..df90bd4133 100644 --- a/protocol/dubbo/impl/hessian.go +++ b/protocol/dubbo/impl/hessian.go @@ -29,13 +29,14 @@ import ( hessian "github.com/apache/dubbo-go-hessian2" "github.com/apache/dubbo-go-hessian2/java_exception" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) type HessianSerializer struct{} @@ -129,7 +130,7 @@ func marshalRequest(encoder *hessian.Encoder, p DubboPackage) ([]byte, error) { logger.Infof("request args are: %+v", request.Params) return nil, perrors.Errorf("@params is not of type: []interface{}") } - types, err := getArgsTypeList(args) + types, err := GetArgsTypeList(args) if err != nil { return nil, perrors.Wrapf(err, " PackRequest(args:%+v)", args) } @@ -392,7 +393,7 @@ func buildServerSidePackageBody(pkg *DubboPackage) { } } -func getArgsTypeList(args []interface{}) (string, error) { +func GetArgsTypeList(args []interface{}) (string, error) { var ( typ string types string diff --git a/protocol/dubbo3/dubbo3_exporter.go b/protocol/dubbo3/dubbo3_exporter.go index a8ac595433..3b997b089d 100644 --- a/protocol/dubbo3/dubbo3_exporter.go +++ b/protocol/dubbo3/dubbo3_exporter.go @@ -22,13 +22,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + tripleConstant "github.com/dubbogo/triple/pkg/common/constant" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index b87c0de97c..9e8801ed4a 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -27,6 +27,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/dubbogo/grpc-go/metadata" tripleConstant "github.com/dubbogo/triple/pkg/common/constant" @@ -37,7 +39,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" invocation_impl "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index 10a932e2b9..6a6e96e265 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -26,6 +26,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/dubbogo/grpc-go" "github.com/dubbogo/grpc-go/metadata" @@ -38,7 +40,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/protocol/dubbo3/health/serverhealth.go b/protocol/dubbo3/health/serverhealth.go new file mode 100644 index 0000000000..e14433ffd8 --- /dev/null +++ b/protocol/dubbo3/health/serverhealth.go @@ -0,0 +1,186 @@ +/* + * 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 health provides a service that exposes server's health and it must be +// imported to enable support for client-side health checks. +package health + +import ( + "context" + "sync" +) + +import ( + logger "github.com/dubbogo/gost/log/logger" + + "github.com/dubbogo/grpc-go/codes" + "github.com/dubbogo/grpc-go/status" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/config" + healthpb "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/health/triple_health_v1" + healthtriple "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/health/triple_health_v1" +) + +// Server implements `service Health`. +type DubbogoHealthServer struct { + healthtriple.UnimplementedHealthServer + mu sync.RWMutex + // If shutdown is true, it's expected all serving status is NOT_SERVING, and + // will stay in NOT_SERVING. + shutdown bool + // statusMap stores the serving status of the services this Server monitors. + statusMap map[string]healthpb.HealthCheckResponse_ServingStatus + updates map[string]map[healthtriple.Health_WatchServer]chan healthpb.HealthCheckResponse_ServingStatus +} + +var healthServer *DubbogoHealthServer + +// NewServer returns a new Server. +func NewServer() *DubbogoHealthServer { + return &DubbogoHealthServer{ + statusMap: map[string]healthpb.HealthCheckResponse_ServingStatus{"": healthpb.HealthCheckResponse_SERVING}, + updates: make(map[string]map[healthtriple.Health_WatchServer]chan healthpb.HealthCheckResponse_ServingStatus), + } +} + +// Check implements `service Health`. +func (s *DubbogoHealthServer) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) { + s.mu.RLock() + defer s.mu.RUnlock() + if servingStatus, ok := s.statusMap[in.Service]; ok { + return &healthpb.HealthCheckResponse{ + Status: servingStatus, + }, nil + } + return nil, status.Error(codes.NotFound, "unknown service") +} + +// Watch implements `service Health`. +func (s *DubbogoHealthServer) Watch(in *healthpb.HealthCheckRequest, stream healthtriple.Health_WatchServer) error { + service := in.Service + // update channel is used for getting service status updates. + update := make(chan healthpb.HealthCheckResponse_ServingStatus, 1) + s.mu.Lock() + // Puts the initial status to the channel. + if servingStatus, ok := s.statusMap[service]; ok { + update <- servingStatus + } else { + update <- healthpb.HealthCheckResponse_SERVICE_UNKNOWN + } + + // Registers the update channel to the correct place in the updates map. + if _, ok := s.updates[service]; !ok { + s.updates[service] = make(map[healthtriple.Health_WatchServer]chan healthpb.HealthCheckResponse_ServingStatus) + } + s.updates[service][stream] = update + defer func() { + s.mu.Lock() + delete(s.updates[service], stream) + s.mu.Unlock() + }() + s.mu.Unlock() + + var lastSentStatus healthpb.HealthCheckResponse_ServingStatus = -1 + for { + select { + // Status updated. Sends the up-to-date status to the client. + case servingStatus := <-update: + if lastSentStatus == servingStatus { + continue + } + lastSentStatus = servingStatus + err := stream.Send(&healthpb.HealthCheckResponse{Status: servingStatus}) + if err != nil { + return status.Error(codes.Canceled, "Stream has ended.") + } + // Context done. Removes the update channel from the updates map. + case <-stream.Context().Done(): + return status.Error(codes.Canceled, "Stream has ended.") + } + } +} + +// SetServingStatus is called when need to reset the serving status of a service +// or insert a new service entry into the statusMap. +func (s *DubbogoHealthServer) SetServingStatus(service string, servingStatus healthpb.HealthCheckResponse_ServingStatus) { + s.mu.Lock() + defer s.mu.Unlock() + if s.shutdown { + logger.Infof("health: status changing for %s to %v is ignored because health service is shutdown", service, servingStatus) + return + } + + s.setServingStatusLocked(service, servingStatus) +} + +func (s *DubbogoHealthServer) setServingStatusLocked(service string, servingStatus healthpb.HealthCheckResponse_ServingStatus) { + s.statusMap[service] = servingStatus + for _, update := range s.updates[service] { + // Clears previous updates, that are not sent to the client, from the channel. + // This can happen if the client is not reading and the server gets flow control limited. + select { + case <-update: + default: + } + // Puts the most recent update to the channel. + update <- servingStatus + } +} + +// Shutdown sets all serving status to NOT_SERVING, and configures the server to +// ignore all future status changes. +// +// This changes serving status for all services. To set status for a particular +// services, call SetServingStatus(). +func (s *DubbogoHealthServer) Shutdown() { + s.mu.Lock() + defer s.mu.Unlock() + s.shutdown = true + for service := range s.statusMap { + s.setServingStatusLocked(service, healthpb.HealthCheckResponse_NOT_SERVING) + } +} + +// Resume sets all serving status to SERVING, and configures the server to +// accept all future status changes. +// +// This changes serving status for all services. To set status for a particular +// services, call SetServingStatus(). +func (s *DubbogoHealthServer) Resume() { + s.mu.Lock() + defer s.mu.Unlock() + s.shutdown = false + for service := range s.statusMap { + s.setServingStatusLocked(service, healthpb.HealthCheckResponse_SERVING) + } +} + +// Set health check interface. +func init() { + healthServer = NewServer() + config.SetProviderService(healthServer) +} + +func SetServingStatusServing(service string) { + healthServer.SetServingStatus(service, healthpb.HealthCheckResponse_SERVING) +} + +func SetServingStatusNotServing(service string) { + healthServer.SetServingStatus(service, healthpb.HealthCheckResponse_NOT_SERVING) +} diff --git a/protocol/dubbo3/health/triple_health_v1/health.pb.go b/protocol/dubbo3/health/triple_health_v1/health.pb.go new file mode 100644 index 0000000000..e8bc5f970c --- /dev/null +++ b/protocol/dubbo3/health/triple_health_v1/health.pb.go @@ -0,0 +1,314 @@ +/* + * 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. + */ + +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.1 +// source: protocol/dubbo3/health/triple_health_v1/health.proto + +package triple_health_v1 + +import ( + reflect "reflect" + sync "sync" +) + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type HealthCheckResponse_ServingStatus int32 + +const ( + HealthCheckResponse_UNKNOWN HealthCheckResponse_ServingStatus = 0 + HealthCheckResponse_SERVING HealthCheckResponse_ServingStatus = 1 + HealthCheckResponse_NOT_SERVING HealthCheckResponse_ServingStatus = 2 + HealthCheckResponse_SERVICE_UNKNOWN HealthCheckResponse_ServingStatus = 3 // Used only by the Watch method. +) + +// Enum value maps for HealthCheckResponse_ServingStatus. +var ( + HealthCheckResponse_ServingStatus_name = map[int32]string{ + 0: "UNKNOWN", + 1: "SERVING", + 2: "NOT_SERVING", + 3: "SERVICE_UNKNOWN", + } + HealthCheckResponse_ServingStatus_value = map[string]int32{ + "UNKNOWN": 0, + "SERVING": 1, + "NOT_SERVING": 2, + "SERVICE_UNKNOWN": 3, + } +) + +func (x HealthCheckResponse_ServingStatus) Enum() *HealthCheckResponse_ServingStatus { + p := new(HealthCheckResponse_ServingStatus) + *p = x + return p +} + +func (x HealthCheckResponse_ServingStatus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (HealthCheckResponse_ServingStatus) Descriptor() protoreflect.EnumDescriptor { + return file_protocol_dubbo3_health_triple_health_v1_health_proto_enumTypes[0].Descriptor() +} + +func (HealthCheckResponse_ServingStatus) Type() protoreflect.EnumType { + return &file_protocol_dubbo3_health_triple_health_v1_health_proto_enumTypes[0] +} + +func (x HealthCheckResponse_ServingStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use HealthCheckResponse_ServingStatus.Descriptor instead. +func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { + return file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescGZIP(), []int{1, 0} +} + +type HealthCheckRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` +} + +func (x *HealthCheckRequest) Reset() { + *x = HealthCheckRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HealthCheckRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HealthCheckRequest) ProtoMessage() {} + +func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message { + mi := &file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead. +func (*HealthCheckRequest) Descriptor() ([]byte, []int) { + return file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescGZIP(), []int{0} +} + +func (x *HealthCheckRequest) GetService() string { + if x != nil { + return x.Service + } + return "" +} + +type HealthCheckResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status HealthCheckResponse_ServingStatus `protobuf:"varint,1,opt,name=status,proto3,enum=grpc.health.v1.HealthCheckResponse_ServingStatus" json:"status,omitempty"` +} + +func (x *HealthCheckResponse) Reset() { + *x = HealthCheckResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HealthCheckResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HealthCheckResponse) ProtoMessage() {} + +func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message { + mi := &file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead. +func (*HealthCheckResponse) Descriptor() ([]byte, []int) { + return file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescGZIP(), []int{1} +} + +func (x *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { + if x != nil { + return x.Status + } + return HealthCheckResponse_UNKNOWN +} + +var File_protocol_dubbo3_health_triple_health_v1_health_proto protoreflect.FileDescriptor + +var file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDesc = []byte{ + 0x0a, 0x34, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x64, 0x75, 0x62, 0x62, 0x6f, + 0x33, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2f, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65, 0x5f, + 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x76, 0x31, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x22, 0x2e, 0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0xb1, 0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, + 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x31, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x4f, 0x0a, 0x0d, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x45, 0x52, 0x56, 0x49, + 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, + 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, + 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x03, 0x32, 0xae, 0x01, 0x0a, 0x06, 0x48, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x50, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x22, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x05, 0x57, 0x61, 0x74, 0x63, 0x68, + 0x12, 0x22, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x2e, 0x76, + 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x68, 0x65, 0x61, 0x6c, + 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x34, 0x5a, 0x32, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x75, 0x62, 0x62, 0x6f, 0x67, + 0x6f, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x6f, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x2f, 0x74, 0x72, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x76, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescOnce sync.Once + file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescData = file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDesc +) + +func file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescGZIP() []byte { + file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescOnce.Do(func() { + file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescData = protoimpl.X.CompressGZIP(file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescData) + }) + return file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDescData +} + +var file_protocol_dubbo3_health_triple_health_v1_health_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_protocol_dubbo3_health_triple_health_v1_health_proto_goTypes = []interface{}{ + (HealthCheckResponse_ServingStatus)(0), // 0: grpc.health.v1.HealthCheckResponse.ServingStatus + (*HealthCheckRequest)(nil), // 1: grpc.health.v1.HealthCheckRequest + (*HealthCheckResponse)(nil), // 2: grpc.health.v1.HealthCheckResponse +} +var file_protocol_dubbo3_health_triple_health_v1_health_proto_depIdxs = []int32{ + 0, // 0: grpc.health.v1.HealthCheckResponse.status:type_name -> grpc.health.v1.HealthCheckResponse.ServingStatus + 1, // 1: grpc.health.v1.Health.Check:input_type -> grpc.health.v1.HealthCheckRequest + 1, // 2: grpc.health.v1.Health.Watch:input_type -> grpc.health.v1.HealthCheckRequest + 2, // 3: grpc.health.v1.Health.Check:output_type -> grpc.health.v1.HealthCheckResponse + 2, // 4: grpc.health.v1.Health.Watch:output_type -> grpc.health.v1.HealthCheckResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_protocol_dubbo3_health_triple_health_v1_health_proto_init() } +func file_protocol_dubbo3_health_triple_health_v1_health_proto_init() { + if File_protocol_dubbo3_health_triple_health_v1_health_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HealthCheckRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HealthCheckResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDesc, + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_protocol_dubbo3_health_triple_health_v1_health_proto_goTypes, + DependencyIndexes: file_protocol_dubbo3_health_triple_health_v1_health_proto_depIdxs, + EnumInfos: file_protocol_dubbo3_health_triple_health_v1_health_proto_enumTypes, + MessageInfos: file_protocol_dubbo3_health_triple_health_v1_health_proto_msgTypes, + }.Build() + File_protocol_dubbo3_health_triple_health_v1_health_proto = out.File + file_protocol_dubbo3_health_triple_health_v1_health_proto_rawDesc = nil + file_protocol_dubbo3_health_triple_health_v1_health_proto_goTypes = nil + file_protocol_dubbo3_health_triple_health_v1_health_proto_depIdxs = nil +} diff --git a/protocol/dubbo3/health/triple_health_v1/health.proto b/protocol/dubbo3/health/triple_health_v1/health.proto new file mode 100644 index 0000000000..ae55348388 --- /dev/null +++ b/protocol/dubbo3/health/triple_health_v1/health.proto @@ -0,0 +1,62 @@ +/* + * 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. + */ + +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto + +syntax = "proto3"; + +package grpc.health.v1; + +option go_package = "github.com/dubbogo/grpc-go/health/triple_health_v1"; + +message HealthCheckRequest { + string service = 1; +} + +message HealthCheckResponse { + enum ServingStatus { + UNKNOWN = 0; + SERVING = 1; + NOT_SERVING = 2; + SERVICE_UNKNOWN = 3; // Used only by the Watch method. + } + ServingStatus status = 1; +} + +service Health { + // If the requested service is unknown, the call will fail with status + // NOT_FOUND. + rpc Check(HealthCheckRequest) returns (HealthCheckResponse); + + // Performs a watch for the serving status of the requested service. + // The server will immediately send back a message indicating the current + // serving status. It will then subsequently send a new message whenever + // the service's serving status changes. + // + // If the requested service is unknown when the call is received, the + // server will send a message setting the serving status to + // SERVICE_UNKNOWN but will *not* terminate the call. If at some + // future point, the serving status of the service becomes known, the + // server will send a new message with the service's serving status. + // + // If the call terminates with status UNIMPLEMENTED, then clients + // should assume this method is not supported and should not retry the + // call. If the call terminates with any other status (including OK), + // clients should retry the call with appropriate exponential backoff. + rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); +} \ No newline at end of file diff --git a/protocol/dubbo3/health/triple_health_v1/health_triple.pb.go b/protocol/dubbo3/health/triple_health_v1/health_triple.pb.go new file mode 100644 index 0000000000..a63d394d57 --- /dev/null +++ b/protocol/dubbo3/health/triple_health_v1/health_triple.pb.go @@ -0,0 +1,286 @@ +/* + * 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. + */ + +// Code generated by protoc-gen-go-triple. DO NOT EDIT. +// versions: +// - protoc-gen-go-triple v1.0.8 +// - protoc v3.20.1 +// source: protocol/dubbo3/health/triple_health_v1/health.proto + +package triple_health_v1 + +import ( + context "context" + fmt "fmt" +) + +import ( + grpc_go "github.com/dubbogo/grpc-go" + codes "github.com/dubbogo/grpc-go/codes" + metadata "github.com/dubbogo/grpc-go/metadata" + status "github.com/dubbogo/grpc-go/status" + + common "github.com/dubbogo/triple/pkg/common" + constant "github.com/dubbogo/triple/pkg/common/constant" + triple "github.com/dubbogo/triple/pkg/triple" +) + +import ( + constant1 "dubbo.apache.org/dubbo-go/v3/common/constant" + protocol "dubbo.apache.org/dubbo-go/v3/protocol" + dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" + invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc_go.SupportPackageIsVersion7 + +// HealthClient is the client API for Health service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type HealthClient interface { + // If the requested service is unknown, the call will fail with status + // NOT_FOUND. + Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (*HealthCheckResponse, common.ErrorWithAttachment) + // Performs a watch for the serving status of the requested service. + // The server will immediately send back a message indicating the current + // serving status. It will then subsequently send a new message whenever + // the service's serving status changes. + // + // If the requested service is unknown when the call is received, the + // server will send a message setting the serving status to + // SERVICE_UNKNOWN but will *not* terminate the call. If at some + // future point, the serving status of the service becomes known, the + // server will send a new message with the service's serving status. + // + // If the call terminates with status UNIMPLEMENTED, then clients + // should assume this method is not supported and should not retry the + // call. If the call terminates with any other status (including OK), + // clients should retry the call with appropriate exponential backoff. + Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (Health_WatchClient, error) +} + +type healthClient struct { + cc *triple.TripleConn +} + +type HealthClientImpl struct { + Check func(ctx context.Context, in *HealthCheckRequest) (*HealthCheckResponse, error) + Watch func(ctx context.Context, in *HealthCheckRequest) (Health_WatchClient, error) +} + +func (c *HealthClientImpl) GetDubboStub(cc *triple.TripleConn) HealthClient { + return NewHealthClient(cc) +} + +func (c *HealthClientImpl) XXX_InterfaceName() string { + return "grpc.health.v1.Health" +} + +func NewHealthClient(cc *triple.TripleConn) HealthClient { + return &healthClient{cc} +} + +func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (*HealthCheckResponse, common.ErrorWithAttachment) { + out := new(HealthCheckResponse) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Check", in, out) +} + +func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc_go.CallOption) (Health_WatchClient, error) { + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/Watch", opts...) + if err != nil { + return nil, err + } + x := &healthWatchClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Health_WatchClient interface { + Recv() (*HealthCheckResponse, error) + grpc_go.ClientStream +} + +type healthWatchClient struct { + grpc_go.ClientStream +} + +func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) { + m := new(HealthCheckResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// HealthServer is the server API for Health service. +// All implementations must embed UnimplementedHealthServer +// for forward compatibility +type HealthServer interface { + // If the requested service is unknown, the call will fail with status + // NOT_FOUND. + Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) + // Performs a watch for the serving status of the requested service. + // The server will immediately send back a message indicating the current + // serving status. It will then subsequently send a new message whenever + // the service's serving status changes. + // + // If the requested service is unknown when the call is received, the + // server will send a message setting the serving status to + // SERVICE_UNKNOWN but will *not* terminate the call. If at some + // future point, the serving status of the service becomes known, the + // server will send a new message with the service's serving status. + // + // If the call terminates with status UNIMPLEMENTED, then clients + // should assume this method is not supported and should not retry the + // call. If the call terminates with any other status (including OK), + // clients should retry the call with appropriate exponential backoff. + Watch(*HealthCheckRequest, Health_WatchServer) error + mustEmbedUnimplementedHealthServer() +} + +// UnimplementedHealthServer must be embedded to have forward compatible implementations. +type UnimplementedHealthServer struct { + proxyImpl protocol.Invoker +} + +func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") +} +func (UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error { + return status.Errorf(codes.Unimplemented, "method Watch not implemented") +} +func (s *UnimplementedHealthServer) XXX_SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *UnimplementedHealthServer) XXX_GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (s *UnimplementedHealthServer) XXX_ServiceDesc() *grpc_go.ServiceDesc { + return &Health_ServiceDesc +} +func (s *UnimplementedHealthServer) XXX_InterfaceName() string { + return "grpc.health.v1.Health" +} + +func (UnimplementedHealthServer) mustEmbedUnimplementedHealthServer() {} + +// UnsafeHealthServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to HealthServer will +// result in compilation errors. +type UnsafeHealthServer interface { + mustEmbedUnimplementedHealthServer() +} + +func RegisterHealthServer(s grpc_go.ServiceRegistrar, srv HealthServer) { + s.RegisterService(&Health_ServiceDesc, srv) +} + +func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { + in := new(HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + base := srv.(dubbo3.Dubbo3GrpcService) + args := []interface{}{} + args = append(args, in) + md, _ := metadata.FromIncomingContext(ctx) + invAttachment := make(map[string]interface{}, len(md)) + for k, v := range md { + invAttachment[k] = v + } + invo := invocation.NewRPCInvocation("Check", args, invAttachment) + if interceptor == nil { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + info := &grpc_go.UnaryServerInfo{ + Server: srv, + FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string), + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + return interceptor(ctx, in, info, handler) +} + +func _Health_Watch_Handler(srv interface{}, stream grpc_go.ServerStream) error { + _, ok := srv.(dubbo3.Dubbo3GrpcService) + ctx := stream.Context() + md, _ := metadata.FromIncomingContext(ctx) + invAttachment := make(map[string]interface{}, len(md)) + for k, v := range md { + invAttachment[k] = v + } + stream.(grpc_go.CtxSetterStream).SetContext(context.WithValue(ctx, constant1.AttachmentKey, invAttachment)) + invo := invocation.NewRPCInvocation("Watch", nil, nil) + if !ok { + fmt.Println(invo) + return nil + } + m := new(HealthCheckRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(HealthServer).Watch(m, &healthWatchServer{stream}) +} + +type Health_WatchServer interface { + Send(*HealthCheckResponse) error + grpc_go.ServerStream +} + +type healthWatchServer struct { + grpc_go.ServerStream +} + +func (x *healthWatchServer) Send(m *HealthCheckResponse) error { + return x.ServerStream.SendMsg(m) +} + +// Health_ServiceDesc is the grpc_go.ServiceDesc for Health service. +// It's only intended for direct use with grpc_go.RegisterService, +// and not to be introspected or modified (even as a copy) +var Health_ServiceDesc = grpc_go.ServiceDesc{ + ServiceName: "grpc.health.v1.Health", + HandlerType: (*HealthServer)(nil), + Methods: []grpc_go.MethodDesc{ + { + MethodName: "Check", + Handler: _Health_Check_Handler, + }, + }, + Streams: []grpc_go.StreamDesc{ + { + StreamName: "Watch", + Handler: _Health_Watch_Handler, + ServerStreams: true, + }, + }, + Metadata: "protocol/dubbo3/health/triple_health_v1/health.proto", +} diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 79ce4797e7..055bf1b9ba 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -21,13 +21,16 @@ import ( "context" ) +import ( + log "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" - log "dubbo.apache.org/dubbo-go/v3/common/logger" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" + _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" ) // server is used to implement helloworld.GreeterServer. diff --git a/protocol/dubbo3/reflection/serverreflection.go b/protocol/dubbo3/reflection/serverreflection.go index 74c7a92a39..caf19c38a3 100644 --- a/protocol/dubbo3/reflection/serverreflection.go +++ b/protocol/dubbo3/reflection/serverreflection.go @@ -60,7 +60,7 @@ type GRPCServer interface { var _ GRPCServer = (*grpc.Server)(nil) -type XXX_serverReflectionServer struct { +type DubbogoServerReflectionServer struct { rpb.UnimplementedServerReflectionServer s GRPCServer @@ -69,7 +69,7 @@ type XXX_serverReflectionServer struct { symbols map[string]*dpb.FileDescriptorProto // map of fully-qualified names to files } -func (r *XXX_serverReflectionServer) SetGRPCServer(s *grpc.Server) { +func (r *DubbogoServerReflectionServer) SetGRPCServer(s *grpc.Server) { r.s = s } @@ -81,7 +81,7 @@ type protoMessage interface { Descriptor() ([]byte, []int) } -func (s *XXX_serverReflectionServer) getSymbols() (svcNames []string, symbolIndex map[string]*dpb.FileDescriptorProto) { +func (s *DubbogoServerReflectionServer) getSymbols() (svcNames []string, symbolIndex map[string]*dpb.FileDescriptorProto) { s.initSymbols.Do(func() { serviceInfo := s.s.GetServiceInfo() @@ -106,7 +106,7 @@ func (s *XXX_serverReflectionServer) getSymbols() (svcNames []string, symbolInde return s.serviceNames, s.symbols } -func (s *XXX_serverReflectionServer) processFile(fd *dpb.FileDescriptorProto, processed map[string]struct{}) { +func (s *DubbogoServerReflectionServer) processFile(fd *dpb.FileDescriptorProto, processed map[string]struct{}) { filename := fd.GetName() if _, ok := processed[filename]; ok { return @@ -143,7 +143,7 @@ func (s *XXX_serverReflectionServer) processFile(fd *dpb.FileDescriptorProto, pr } } -func (s *XXX_serverReflectionServer) processMessage(fd *dpb.FileDescriptorProto, prefix string, msg *dpb.DescriptorProto) { +func (s *DubbogoServerReflectionServer) processMessage(fd *dpb.FileDescriptorProto, prefix string, msg *dpb.DescriptorProto) { msgName := fqn(prefix, msg.GetName()) s.symbols[msgName] = fd @@ -165,7 +165,7 @@ func (s *XXX_serverReflectionServer) processMessage(fd *dpb.FileDescriptorProto, } } -func (s *XXX_serverReflectionServer) processEnum(fd *dpb.FileDescriptorProto, prefix string, en *dpb.EnumDescriptorProto) { +func (s *DubbogoServerReflectionServer) processEnum(fd *dpb.FileDescriptorProto, prefix string, en *dpb.EnumDescriptorProto) { enName := fqn(prefix, en.GetName()) s.symbols[enName] = fd @@ -175,7 +175,7 @@ func (s *XXX_serverReflectionServer) processEnum(fd *dpb.FileDescriptorProto, pr } } -func (s *XXX_serverReflectionServer) processField(fd *dpb.FileDescriptorProto, prefix string, fld *dpb.FieldDescriptorProto) { +func (s *DubbogoServerReflectionServer) processField(fd *dpb.FileDescriptorProto, prefix string, fld *dpb.FieldDescriptorProto) { fldName := fqn(prefix, fld.GetName()) s.symbols[fldName] = fd } @@ -189,7 +189,7 @@ func fqn(prefix, name string) string { // fileDescForType gets the file descriptor for the given type. // The given type should be a proto message. -func (s *XXX_serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) { +func (s *DubbogoServerReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) { m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", st) @@ -258,7 +258,7 @@ func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescripto return decodeFileDesc(proto.FileDescriptor(extDesc.Filename)) } -func (s *XXX_serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) { +func (s *DubbogoServerReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) { m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", st) @@ -304,7 +304,7 @@ func fileDescWithDependencies(fd *dpb.FileDescriptorProto, sentFileDescriptors m // fileDescEncodingByFilename finds the file descriptor for given filename, // finds all of its previously unsent transitive dependencies, does marshaling // on them, and returns the marshaled result. -func (s *XXX_serverReflectionServer) fileDescEncodingByFilename(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { +func (s *DubbogoServerReflectionServer) fileDescEncodingByFilename(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { enc := proto.FileDescriptor(name) if enc == nil { return nil, fmt.Errorf("unknown file: %v", name) @@ -338,7 +338,7 @@ func parseMetadata(meta interface{}) ([]byte, bool) { // given symbol, finds all of its previously unsent transitive dependencies, // does marshaling on them, and returns the marshaled result. The given symbol // can be a type, a service or a method. -func (s *XXX_serverReflectionServer) fileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { +func (s *DubbogoServerReflectionServer) fileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) { _, symbols := s.getSymbols() // if strings.HasPrefix(name, "grpc.") { @@ -367,7 +367,7 @@ func (s *XXX_serverReflectionServer) fileDescEncodingContainingSymbol(name strin // fileDescEncodingContainingExtension finds the file descriptor containing // given extension, finds all of its previously unsent transitive dependencies, // does marshaling on them, and returns the marshaled result. -func (s *XXX_serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) { +func (s *DubbogoServerReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) { st, err := typeForName(typeName) if err != nil { return nil, err @@ -380,7 +380,7 @@ func (s *XXX_serverReflectionServer) fileDescEncodingContainingExtension(typeNam } // allExtensionNumbersForTypeName returns all extension numbers for the given type. -func (s *XXX_serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) { +func (s *DubbogoServerReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) { st, err := typeForName(name) if err != nil { return nil, err @@ -393,7 +393,7 @@ func (s *XXX_serverReflectionServer) allExtensionNumbersForTypeName(name string) } // ServerReflectionInfo is the reflection service handler. -func (s *XXX_serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflection_ServerReflectionInfoServer) error { +func (s *DubbogoServerReflectionServer) ServerReflectionInfo(stream rpb.ServerReflection_ServerReflectionInfoServer) error { sentFileDescriptors := make(map[string]bool) for { in, err := stream.Recv() @@ -493,5 +493,5 @@ func (s *XXX_serverReflectionServer) ServerReflectionInfo(stream rpb.ServerRefle } } func init() { - config.SetProviderService(&XXX_serverReflectionServer{}) + config.SetProviderService(&DubbogoServerReflectionServer{}) } diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index b6f2b03f58..f316d931c1 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" "github.com/opentracing/opentracing-go" @@ -37,7 +39,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" ) diff --git a/protocol/grpc/grpc_exporter.go b/protocol/grpc/grpc_exporter.go index a5f00450d0..464ce39f1f 100644 --- a/protocol/grpc/grpc_exporter.go +++ b/protocol/grpc/grpc_exporter.go @@ -21,10 +21,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/grpc/grpc_invoker.go b/protocol/grpc/grpc_invoker.go index 8c535c5661..6e4c381023 100644 --- a/protocol/grpc/grpc_invoker.go +++ b/protocol/grpc/grpc_invoker.go @@ -26,6 +26,8 @@ import ( import ( hessian2 "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" + "github.com/pkg/errors" "google.golang.org/grpc/connectivity" @@ -33,7 +35,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go index 6b8596b725..5521109f4d 100644 --- a/protocol/grpc/grpc_protocol.go +++ b/protocol/grpc/grpc_protocol.go @@ -22,11 +22,14 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/grpc/internal/helloworld/server.go b/protocol/grpc/internal/helloworld/server.go index cf12571f6a..d855c0a26b 100644 --- a/protocol/grpc/internal/helloworld/server.go +++ b/protocol/grpc/internal/helloworld/server.go @@ -23,11 +23,9 @@ import ( ) import ( - "google.golang.org/grpc" -) + log "github.com/dubbogo/gost/log/logger" -import ( - log "dubbo.apache.org/dubbo-go/v3/common/logger" + "google.golang.org/grpc" ) // server is used to implement helloworld.GreeterServer. diff --git a/protocol/grpc/internal/routeguide/client.go b/protocol/grpc/internal/routeguide/client.go index 8e9bdbe145..542667ef5c 100644 --- a/protocol/grpc/internal/routeguide/client.go +++ b/protocol/grpc/internal/routeguide/client.go @@ -24,7 +24,10 @@ import ( ) import ( - log "dubbo.apache.org/dubbo-go/v3/common/logger" + log "github.com/dubbogo/gost/log/logger" +) + +import ( "dubbo.apache.org/dubbo-go/v3/config" ) diff --git a/protocol/grpc/internal/routeguide/server.go b/protocol/grpc/internal/routeguide/server.go index d13fab5d71..77a36fd3b1 100644 --- a/protocol/grpc/internal/routeguide/server.go +++ b/protocol/grpc/internal/routeguide/server.go @@ -29,15 +29,13 @@ import ( ) import ( + log "github.com/dubbogo/gost/log/logger" + "github.com/golang/protobuf/proto" "google.golang.org/grpc" ) -import ( - log "dubbo.apache.org/dubbo-go/v3/common/logger" -) - type routeGuideServer struct { *RouteGuideProviderBase savedFeatures []*Feature // read-only after initialized diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index dc16074f7c..d938af857f 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" "github.com/opentracing/opentracing-go" @@ -35,7 +37,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index c477c7d6a1..5c821e6768 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -234,7 +234,7 @@ func (r *RPCInvocation) GetAttributeWithDefaultValue(key string, defaultValue in if r.attributes == nil { return defaultValue } - if value, ok := r.attachments[key]; ok { + if value, ok := r.attributes[key]; ok { return value } return defaultValue diff --git a/protocol/invoker.go b/protocol/invoker.go index e219c4d535..ecd36cd375 100644 --- a/protocol/invoker.go +++ b/protocol/invoker.go @@ -23,6 +23,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" uatomic "go.uber.org/atomic" @@ -30,7 +32,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) var ( diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index f111534843..2a62c46179 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -33,6 +33,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/opentracing/opentracing-go" perrors "github.com/pkg/errors" @@ -41,7 +43,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // Request is HTTP protocol request diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index 855c918b62..d214b1b49a 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -44,7 +44,7 @@ import ( //import ( // "dubbo.apache.org/dubbo-go/v3/common" // "dubbo.apache.org/dubbo-go/v3/common/constant" -// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" // "dubbo.apache.org/dubbo-go/v3/protocol" //) // diff --git a/protocol/jsonrpc/jsonrpc_exporter.go b/protocol/jsonrpc/jsonrpc_exporter.go index a1b85a0147..6cdfb46c52 100644 --- a/protocol/jsonrpc/jsonrpc_exporter.go +++ b/protocol/jsonrpc/jsonrpc_exporter.go @@ -21,10 +21,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go index 03b3280640..2e28362e05 100644 --- a/protocol/jsonrpc/jsonrpc_invoker.go +++ b/protocol/jsonrpc/jsonrpc_invoker.go @@ -21,10 +21,13 @@ import ( "context" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" invocation_impl "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/protocol/jsonrpc/jsonrpc_invoker_test.go b/protocol/jsonrpc/jsonrpc_invoker_test.go index 6f762fe2ea..f2c2deb6b7 100644 --- a/protocol/jsonrpc/jsonrpc_invoker_test.go +++ b/protocol/jsonrpc/jsonrpc_invoker_test.go @@ -30,7 +30,7 @@ package jsonrpc // //import ( // "dubbo.apache.org/dubbo-go/v3/common" -// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" // "dubbo.apache.org/dubbo-go/v3/protocol" // "dubbo.apache.org/dubbo-go/v3/protocol/invocation" //) diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index d5bcf965d5..16ca254233 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -23,11 +23,14 @@ import ( "time" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index 340849c337..4470cb277a 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -32,6 +32,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/opentracing/opentracing-go" perrors "github.com/pkg/errors" @@ -40,7 +42,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/protocol/protocol.go b/protocol/protocol.go index c8f9893d80..abd83c9962 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -21,9 +21,12 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // Protocol is the interface that wraps the basic Export、 Refer and Destroy method. diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go index 548a1f524b..6c1023a0e9 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper.go @@ -22,11 +22,14 @@ import ( "strings" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 7862e4e176..df6d948023 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/stretchr/testify/assert" ) @@ -31,7 +33,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/rest/config/reader/rest_config_reader.go b/protocol/rest/config/reader/rest_config_reader.go index 6bfe5c2caa..57565c92d7 100644 --- a/protocol/rest/config/reader/rest_config_reader.go +++ b/protocol/rest/config/reader/rest_config_reader.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" "gopkg.in/yaml.v2" @@ -32,7 +34,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config/interfaces" "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" ) diff --git a/protocol/rest/config/reader/rest_config_reader_test.go b/protocol/rest/config/reader/rest_config_reader_test.go index 78acde21fe..71f8a0b126 100644 --- a/protocol/rest/config/reader/rest_config_reader_test.go +++ b/protocol/rest/config/reader/rest_config_reader_test.go @@ -23,11 +23,12 @@ import ( ) import ( + "github.com/dubbogo/gost/encoding/yaml" + "github.com/stretchr/testify/assert" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/yaml" "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" ) diff --git a/protocol/rest/rest_exporter.go b/protocol/rest/rest_exporter.go index b3e3a4814c..9bc27da2db 100644 --- a/protocol/rest/rest_exporter.go +++ b/protocol/rest/rest_exporter.go @@ -21,10 +21,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go index 32d007aa7c..303b453533 100644 --- a/protocol/rest/rest_protocol.go +++ b/protocol/rest/rest_protocol.go @@ -22,11 +22,14 @@ import ( "time" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" _ "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 8d45399e66..d216217a63 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -34,7 +34,7 @@ package rest //import ( // "dubbo.apache.org/dubbo-go/v3/common" // "dubbo.apache.org/dubbo-go/v3/common/extension" -// _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" // "dubbo.apache.org/dubbo-go/v3/config" // rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" //) diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index 328d1480cf..a41aaf937a 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -26,12 +26,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 77ed67dadd..642d28b67a 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -27,6 +27,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "github.com/emicklei/go-restful/v3" perrors "github.com/pkg/errors" @@ -36,7 +38,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" "dubbo.apache.org/dubbo-go/v3/protocol/rest/server" ) diff --git a/protocol/rpc_status.go b/protocol/rpc_status.go index f2b2aa4e0d..4452d75f1b 100644 --- a/protocol/rpc_status.go +++ b/protocol/rpc_status.go @@ -24,13 +24,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + uberAtomic "go.uber.org/atomic" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) var ( diff --git a/common/proxy/proxy.go b/proxy/proxy.go similarity index 99% rename from common/proxy/proxy.go rename to proxy/proxy.go index 016d293a56..72da5904f7 100644 --- a/common/proxy/proxy.go +++ b/proxy/proxy.go @@ -27,13 +27,14 @@ import ( import ( "github.com/apache/dubbo-go-hessian2/java_exception" + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" invocation_impl "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/common/proxy/proxy_factory.go b/proxy/proxy_factory.go similarity index 100% rename from common/proxy/proxy_factory.go rename to proxy/proxy_factory.go diff --git a/common/proxy/proxy_factory/default.go b/proxy/proxy_factory/default.go similarity index 98% rename from common/proxy/proxy_factory/default.go rename to proxy/proxy_factory/default.go index 926dc17786..d35d02cc14 100644 --- a/common/proxy/proxy_factory/default.go +++ b/proxy/proxy_factory/default.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -31,9 +33,8 @@ import ( "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/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/proxy" "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/proxy" ) func init() { diff --git a/common/proxy/proxy_factory/default_test.go b/proxy/proxy_factory/default_test.go similarity index 100% rename from common/proxy/proxy_factory/default_test.go rename to proxy/proxy_factory/default_test.go diff --git a/common/proxy/proxy_factory/pass_through.go b/proxy/proxy_factory/pass_through.go similarity index 97% rename from common/proxy/proxy_factory/pass_through.go rename to proxy/proxy_factory/pass_through.go index 38cb2581b6..5739e12e3a 100644 --- a/common/proxy/proxy_factory/pass_through.go +++ b/proxy/proxy_factory/pass_through.go @@ -23,6 +23,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -30,9 +32,8 @@ import ( "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/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/proxy" "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/proxy" ) func init() { diff --git a/common/proxy/proxy_factory/pass_through_test.go b/proxy/proxy_factory/pass_through_test.go similarity index 100% rename from common/proxy/proxy_factory/pass_through_test.go rename to proxy/proxy_factory/pass_through_test.go diff --git a/common/proxy/proxy_factory/utils.go b/proxy/proxy_factory/utils.go similarity index 100% rename from common/proxy/proxy_factory/utils.go rename to proxy/proxy_factory/utils.go diff --git a/common/proxy/proxy_test.go b/proxy/proxy_test.go similarity index 100% rename from common/proxy/proxy_test.go rename to proxy/proxy_test.go diff --git a/registry/base_configuration_listener.go b/registry/base_configuration_listener.go index f82e834d2a..88f1867645 100644 --- a/registry/base_configuration_listener.go +++ b/registry/base_configuration_listener.go @@ -18,6 +18,8 @@ package registry import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -25,7 +27,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/registry/base_registry.go b/registry/base_registry.go index 1016d88c07..569236e33a 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -28,13 +28,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) const ( diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 47337954e1..bef438b63c 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -36,7 +38,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" _ "dubbo.apache.org/dubbo-go/v3/config_center/configurator" diff --git a/registry/etcdv3/listener.go b/registry/etcdv3/listener.go index 92e55aa093..8eefd95240 100644 --- a/registry/etcdv3/listener.go +++ b/registry/etcdv3/listener.go @@ -24,13 +24,13 @@ import ( import ( gxchan "github.com/dubbogo/gost/container/chan" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index d2773312e9..9a86bef0b3 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -26,6 +26,7 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -34,7 +35,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting/etcdv3" ) diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index 3f5d31b80d..59cb096c9a 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -27,6 +27,7 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" gxpage "github.com/dubbogo/gost/hash/page" + "github.com/dubbogo/gost/log/logger" "github.com/hashicorp/vault/sdk/helper/jsonutil" ) @@ -35,7 +36,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" "dubbo.apache.org/dubbo-go/v3/remoting/etcdv3" diff --git a/registry/event.go b/registry/event.go index 5d46f02d68..13e066e908 100644 --- a/registry/event.go +++ b/registry/event.go @@ -23,9 +23,12 @@ import ( "time" ) +import ( + "github.com/dubbogo/gost/gof/observer" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/observer" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/registry/event/base_configuration_listener.go b/registry/event/base_configuration_listener.go index a9e2106fec..73843116e9 100644 --- a/registry/event/base_configuration_listener.go +++ b/registry/event/base_configuration_listener.go @@ -18,6 +18,8 @@ package event import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -25,7 +27,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/registry/event/metadata_service_url_params_customizer.go b/registry/event/metadata_service_url_params_customizer.go index 4b599d8b6a..48d8beddae 100644 --- a/registry/event/metadata_service_url_params_customizer.go +++ b/registry/event/metadata_service_url_params_customizer.go @@ -23,13 +23,13 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/log/logger" ) import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" ) diff --git a/registry/event/protocol_ports_metadata_customizer.go b/registry/event/protocol_ports_metadata_customizer.go index 7113fa4e90..8eeda26e0e 100644 --- a/registry/event/protocol_ports_metadata_customizer.go +++ b/registry/event/protocol_ports_metadata_customizer.go @@ -22,10 +22,13 @@ import ( "strconv" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" ) diff --git a/registry/event/service_instances_changed_listener_impl.go b/registry/event/service_instances_changed_listener_impl.go index e3f20992c0..a9ce70a52f 100644 --- a/registry/event/service_instances_changed_listener_impl.go +++ b/registry/event/service_instances_changed_listener_impl.go @@ -23,14 +23,14 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/gof/observer" + "github.com/dubbogo/gost/log/logger" ) import ( "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/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/observer" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/registry/event/service_revision_customizer.go b/registry/event/service_revision_customizer.go index c648eedd94..62b5a91f79 100644 --- a/registry/event/service_revision_customizer.go +++ b/registry/event/service_revision_customizer.go @@ -23,11 +23,14 @@ import ( "sort" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" ) diff --git a/registry/mock_registry.go b/registry/mock_registry.go index fe9b0078b3..8f4505c75a 100644 --- a/registry/mock_registry.go +++ b/registry/mock_registry.go @@ -23,12 +23,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "go.uber.org/atomic" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // MockRegistry is used as mock registry diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go index 92b4e7742f..230630e7dd 100644 --- a/registry/nacos/listener.go +++ b/registry/nacos/listener.go @@ -28,6 +28,7 @@ import ( import ( gxchan "github.com/dubbogo/gost/container/chan" nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" @@ -38,7 +39,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index 579cfef404..509ca8e7be 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -26,6 +26,7 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" "github.com/nacos-group/nacos-sdk-go/vo" @@ -36,7 +37,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting/nacos" ) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 750b30561d..313bb014d6 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -23,9 +23,10 @@ import ( ) import ( - "github.com/dubbogo/gost/container/set" + gxset "github.com/dubbogo/gost/container/set" nacosClient "github.com/dubbogo/gost/database/kv/nacos" - "github.com/dubbogo/gost/hash/page" + gxpage "github.com/dubbogo/gost/hash/page" + "github.com/dubbogo/gost/log/logger" "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" @@ -37,7 +38,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting/nacos" ) diff --git a/registry/polaris/listener.go b/registry/polaris/listener.go index 4da78caa9f..c7927605c2 100644 --- a/registry/polaris/listener.go +++ b/registry/polaris/listener.go @@ -18,13 +18,13 @@ package polaris import ( - "bytes" "net/url" "strconv" ) import ( gxchan "github.com/dubbogo/gost/container/chan" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" @@ -33,8 +33,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/registry" ) @@ -78,13 +76,6 @@ func (pl *polarisListener) Close() { close(pl.closeCh) } -func getSubscribeName(url *common.URL) string { - var buffer bytes.Buffer - buffer.Write([]byte(common.DubboNodes[common.PROVIDER])) - appendParam(&buffer, url, constant.InterfaceKey) - return buffer.String() -} - func generateUrl(instance model.Instance) *common.URL { if instance.GetMetadata() == nil { logger.Errorf("polaris instance metadata is empty,instance:%+v", instance) diff --git a/registry/polaris/registry.go b/registry/polaris/registry.go index eed59fb061..0ead232741 100644 --- a/registry/polaris/registry.go +++ b/registry/polaris/registry.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" "github.com/polarismesh/polaris-go/api" @@ -35,10 +37,7 @@ import ( "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/common/logger" - "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/registry" - "dubbo.apache.org/dubbo-go/v3/remoting" "dubbo.apache.org/dubbo-go/v3/remoting/polaris" ) @@ -61,12 +60,10 @@ func newPolarisRegistry(url *common.URL) (registry.Registry, error) { return &polarisRegistry{}, err } pRegistry := &polarisRegistry{ - consumer: api.NewConsumerAPIByContext(sdkCtx), provider: api.NewProviderAPIByContext(sdkCtx), lock: &sync.RWMutex{}, registryUrls: make(map[string]*PolarisHeartbeat), listenerLock: &sync.RWMutex{}, - watchers: make(map[string]*PolarisServiceWatcher), } return pRegistry, nil @@ -74,13 +71,11 @@ func newPolarisRegistry(url *common.URL) (registry.Registry, error) { type polarisRegistry struct { url *common.URL - consumer api.ConsumerAPI provider api.ProviderAPI lock *sync.RWMutex registryUrls map[string]*PolarisHeartbeat listenerLock *sync.RWMutex - watchers map[string]*PolarisServiceWatcher } // Register will register the service @url to its polaris registry center. @@ -160,12 +155,6 @@ func (pr *polarisRegistry) Subscribe(url *common.URL, notifyListener registry.No return nil } - watcher, err := pr.createPolarisWatcherIfAbsent(url) - - if err != nil { - return err - } - for { listener, err := NewPolarisListener(url) if err != nil { @@ -174,13 +163,6 @@ func (pr *polarisRegistry) Subscribe(url *common.URL, notifyListener registry.No continue } - watcher.AddSubscriber(func(et remoting.EventType, instances []model.Instance) { - for i := range instances { - instance := instances[i] - listener.events.In() <- &config_center.ConfigChangeEvent{ConfigType: et, Value: instance} - } - }) - for { serviceEvent, err := listener.Next() if err != nil { @@ -194,33 +176,6 @@ func (pr *polarisRegistry) Subscribe(url *common.URL, notifyListener registry.No } } -func (pr *polarisRegistry) createPolarisWatcherIfAbsent(url *common.URL) (*PolarisServiceWatcher, error) { - - pr.listenerLock.Lock() - defer pr.listenerLock.Unlock() - - serviceName := getSubscribeName(url) - - if _, exist := pr.watchers[serviceName]; !exist { - subscribeParam := &api.WatchServiceRequest{ - WatchServiceRequest: model.WatchServiceRequest{ - Key: model.ServiceKey{ - Namespace: url.GetParam(constant.PolarisNamespace, constant.PolarisDefaultNamespace), - Service: serviceName, - }, - }, - } - - watcher, err := newPolarisWatcher(subscribeParam, pr.consumer) - if err != nil { - return nil, err - } - pr.watchers[serviceName] = watcher - } - - return pr.watchers[serviceName], nil -} - // UnSubscribe returns nil if unsubscribing registry successfully. If not returns an error. func (pr *polarisRegistry) UnSubscribe(url *common.URL, notifyListener registry.NotifyListener) error { // TODO wait polaris support it diff --git a/registry/polaris/service_discovery.go b/registry/polaris/service_discovery.go index 5f0b315ee7..c4d6f189be 100644 --- a/registry/polaris/service_discovery.go +++ b/registry/polaris/service_discovery.go @@ -28,6 +28,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" gxpage "github.com/dubbogo/gost/hash/page" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" @@ -38,7 +39,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index dad12df203..50f60e3d0a 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -26,6 +26,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -34,11 +35,11 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" _ "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/health" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "dubbo.apache.org/dubbo-go/v3/registry" _ "dubbo.apache.org/dubbo-go/v3/registry/directory" @@ -191,6 +192,9 @@ func (proto *registryProtocol) Export(originInvoker protocol.Invoker) protocol.E // export invoker exporter := proto.doLocalExport(originInvoker, providerUrl) + // update health status + health.SetServingStatusServing(registryUrl.Service()) + if len(registryUrl.Protocol) > 0 { // url to registry reg := proto.getRegistry(registryUrl) diff --git a/registry/service_instance.go b/registry/service_instance.go index dfb7676c90..6dc1061c19 100644 --- a/registry/service_instance.go +++ b/registry/service_instance.go @@ -23,13 +23,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" gxsort "github.com/dubbogo/gost/sort" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // ServiceInstance is the interface which is used for service registration and discovery. diff --git a/registry/service_instances_changed_listener.go b/registry/service_instances_changed_listener.go index 6b2704ac8b..940b126a3b 100644 --- a/registry/service_instances_changed_listener.go +++ b/registry/service_instances_changed_listener.go @@ -23,10 +23,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" + "github.com/dubbogo/gost/gof/observer" ) // ServiceInstancesChangedListener is the interface of the Service Discovery Changed Event Listener diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 70716e9d50..6d1362b749 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -25,6 +25,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" @@ -35,7 +36,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" diff --git a/registry/xds/registry.go b/registry/xds/registry.go index b3f71b04f6..f8d51cc5c1 100644 --- a/registry/xds/registry.go +++ b/registry/xds/registry.go @@ -25,6 +25,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) @@ -32,7 +34,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting/xds" common2 "dubbo.apache.org/dubbo-go/v3/remoting/xds/common" diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 51a4346872..860b48deca 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -25,6 +25,7 @@ import ( import ( gxchan "github.com/dubbogo/gost/container/chan" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -32,7 +33,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 109b33e00f..c3cb6136c9 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -29,6 +29,7 @@ import ( "github.com/dubbogo/go-zookeeper/zk" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) @@ -37,7 +38,6 @@ import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting/zookeeper" ) diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index fc9466f9bd..dfc3a0d73a 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -28,13 +28,13 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" gxpage "github.com/dubbogo/gost/hash/page" + "github.com/dubbogo/gost/log/logger" ) import ( "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/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" "dubbo.apache.org/dubbo-go/v3/remoting/zookeeper" diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index e0b423c797..477fa5eefe 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -37,7 +37,7 @@ package zookeeper // "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/common/observer" +// "github.com/dubbogo/gost/gof/observer" // "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" // "dubbo.apache.org/dubbo-go/v3/config" // "dubbo.apache.org/dubbo-go/v3/metadata/mapping" diff --git a/remoting/etcdv3/client.go b/remoting/etcdv3/client.go index bc6e5e469c..863c11c535 100644 --- a/remoting/etcdv3/client.go +++ b/remoting/etcdv3/client.go @@ -19,14 +19,11 @@ package etcdv3 import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" -) - // ValidateClient validates client and sets options func ValidateClient(container clientFacade, opts ...gxetcd.Option) error { options := &gxetcd.Options{} diff --git a/remoting/etcdv3/facade.go b/remoting/etcdv3/facade.go index 7cdabafba9..ed59fd56d8 100644 --- a/remoting/etcdv3/facade.go +++ b/remoting/etcdv3/facade.go @@ -24,11 +24,11 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + "github.com/dubbogo/gost/log/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) type clientFacade interface { diff --git a/remoting/etcdv3/listener.go b/remoting/etcdv3/listener.go index 6cd677e777..86b5643a82 100644 --- a/remoting/etcdv3/listener.go +++ b/remoting/etcdv3/listener.go @@ -24,6 +24,7 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" @@ -33,7 +34,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/remoting/exchange.go b/remoting/exchange.go index 6414d0842c..536dd58762 100644 --- a/remoting/exchange.go +++ b/remoting/exchange.go @@ -24,12 +24,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "go.uber.org/atomic" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) var ( diff --git a/remoting/exchange_client.go b/remoting/exchange_client.go index 464437c4d7..ffc936592c 100644 --- a/remoting/exchange_client.go +++ b/remoting/exchange_client.go @@ -23,12 +23,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + uatomic "go.uber.org/atomic" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 4594377863..e523af1810 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -24,8 +24,9 @@ import ( ) import ( - "github.com/apache/dubbo-getty" + getty "github.com/apache/dubbo-getty" + "github.com/dubbogo/gost/log/logger" gxsync "github.com/dubbogo/gost/sync" gxtime "github.com/dubbogo/gost/time" @@ -39,7 +40,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go index 3d4216b403..1135a2d5f1 100644 --- a/remoting/getty/getty_client_test.go +++ b/remoting/getty/getty_client_test.go @@ -37,10 +37,10 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" . "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index f63694164e..8dc0ee1bd6 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -24,8 +24,9 @@ import ( ) import ( - "github.com/apache/dubbo-getty" + getty "github.com/apache/dubbo-getty" + "github.com/dubbogo/gost/log/logger" gxsync "github.com/dubbogo/gost/sync" perrors "github.com/pkg/errors" @@ -36,7 +37,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/remoting/getty/listener.go b/remoting/getty/listener.go index 89fc961c29..9b27b1645c 100644 --- a/remoting/getty/listener.go +++ b/remoting/getty/listener.go @@ -24,10 +24,11 @@ import ( ) import ( - "github.com/apache/dubbo-getty" + getty "github.com/apache/dubbo-getty" hessian "github.com/apache/dubbo-go-hessian2" + "github.com/dubbogo/gost/log/logger" gxtime "github.com/dubbogo/gost/time" perrors "github.com/pkg/errors" @@ -35,7 +36,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/remoting/getty/pool.go b/remoting/getty/pool.go index c7c037d3ec..2974809515 100644 --- a/remoting/getty/pool.go +++ b/remoting/getty/pool.go @@ -28,13 +28,14 @@ import ( ) import ( - "github.com/apache/dubbo-getty" + getty "github.com/apache/dubbo-getty" + + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" ) diff --git a/remoting/getty/readwriter.go b/remoting/getty/readwriter.go index b3956e171a..fad97645c3 100644 --- a/remoting/getty/readwriter.go +++ b/remoting/getty/readwriter.go @@ -22,13 +22,14 @@ import ( ) import ( - "github.com/apache/dubbo-getty" + getty "github.com/apache/dubbo-getty" + + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go index 48e4b3f76e..52c748b0a6 100644 --- a/remoting/getty/readwriter_test.go +++ b/remoting/getty/readwriter_test.go @@ -33,10 +33,10 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go index 8f1f0b84e8..bc8ebccbd8 100644 --- a/remoting/nacos/builder.go +++ b/remoting/nacos/builder.go @@ -26,6 +26,7 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/dubbogo/gost/log/logger" nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant" @@ -35,7 +36,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" ) diff --git a/remoting/xds/client.go b/remoting/xds/client.go index 3cdffc10d7..0592e5bb11 100644 --- a/remoting/xds/client.go +++ b/remoting/xds/client.go @@ -24,12 +24,13 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/registry" xdsCommon "dubbo.apache.org/dubbo-go/v3/remoting/xds/common" diff --git a/remoting/xds/error.go b/remoting/xds/error.go index 2711cf7a79..29c899c9f1 100644 --- a/remoting/xds/error.go +++ b/remoting/xds/error.go @@ -22,6 +22,6 @@ import ( ) var ( - DiscoverLocalError = errors.New("Discovery local Pod's host from xds, failed please register service with endpoint to k8s ") + DiscoverLocalError = errors.New("Discovery local Pod's host from xds failed, please register service with endpoint to k8s ") DiscoverIstiodPodIpError = errors.New("Discovery istiod Pod's ip from xds failed, please register service with endpoint to k8s ") ) diff --git a/remoting/xds/ewatcher/ewatcher.go b/remoting/xds/ewatcher/ewatcher.go index 304c7daae6..33f24f4dae 100644 --- a/remoting/xds/ewatcher/ewatcher.go +++ b/remoting/xds/ewatcher/ewatcher.go @@ -23,10 +23,13 @@ import ( "sync" ) +import ( + "github.com/dubbogo/gost/log/logger" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/remoting" xdsCommon "dubbo.apache.org/dubbo-go/v3/remoting/xds/common" diff --git a/remoting/xds/mapping/handler.go b/remoting/xds/mapping/handler.go index 36489a91e5..b306b62b1f 100644 --- a/remoting/xds/mapping/handler.go +++ b/remoting/xds/mapping/handler.go @@ -27,13 +27,14 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + structpb "github.com/golang/protobuf/ptypes/struct" perrors "github.com/pkg/errors" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting/xds/common" "dubbo.apache.org/dubbo-go/v3/xds/client" ) diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index a12560b214..155f9193d7 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -23,13 +23,13 @@ import ( import ( gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) const ( diff --git a/remoting/zookeeper/curator_discovery/service_discovery.go b/remoting/zookeeper/curator_discovery/service_discovery.go index ab9c475433..0fdc9288a4 100644 --- a/remoting/zookeeper/curator_discovery/service_discovery.go +++ b/remoting/zookeeper/curator_discovery/service_discovery.go @@ -28,13 +28,13 @@ import ( "github.com/dubbogo/go-zookeeper/zk" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting" "dubbo.apache.org/dubbo-go/v3/remoting/zookeeper" ) diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go index f9a4d59521..13d61cc72d 100644 --- a/remoting/zookeeper/facade.go +++ b/remoting/zookeeper/facade.go @@ -24,11 +24,11 @@ import ( import ( gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) type ZkClientFacade interface { diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 15cc14b580..26804732bc 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -28,6 +28,7 @@ import ( "github.com/dubbogo/go-zookeeper/zk" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + "github.com/dubbogo/gost/log/logger" perrors "github.com/pkg/errors" @@ -37,7 +38,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/xds/balancer/cdsbalancer/cdsbalancer.go b/xds/balancer/cdsbalancer/cdsbalancer.go index 3907a795ed..621c2a0b98 100644 --- a/xds/balancer/cdsbalancer/cdsbalancer.go +++ b/xds/balancer/cdsbalancer/cdsbalancer.go @@ -31,6 +31,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" @@ -45,7 +47,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/balancer/clusterresolver" "dubbo.apache.org/dubbo-go/v3/xds/balancer/ringhash" "dubbo.apache.org/dubbo-go/v3/xds/client" @@ -97,7 +98,7 @@ func (bb) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Bal done: grpcsync.NewEvent(), xdsHI: xdsinternal.NewHandshakeInfo(nil, nil), } - b.logger = dubboLogger.GetLogger() + b.logger = dubbogoLogger.GetLogger() b.logger.Infof("Created") var creds credentials.TransportCredentials switch { @@ -172,7 +173,7 @@ type cdsBalancer struct { xdsClient client.XDSClient // xDS client to watch Cluster resource. clusterHandler *clusterHandler // To watch the clusters. childLB balancer.Balancer - logger dubboLogger.Logger + logger dubbogoLogger.Logger closed *grpcsync.Event done *grpcsync.Event diff --git a/xds/balancer/clusterimpl/clusterimpl.go b/xds/balancer/clusterimpl/clusterimpl.go index c18c9a4120..b998581b6f 100644 --- a/xds/balancer/clusterimpl/clusterimpl.go +++ b/xds/balancer/clusterimpl/clusterimpl.go @@ -36,6 +36,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" @@ -46,7 +48,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" internal "dubbo.apache.org/dubbo-go/v3/xds" "dubbo.apache.org/dubbo-go/v3/xds/balancer/loadstore" "dubbo.apache.org/dubbo-go/v3/xds/client" @@ -80,7 +81,7 @@ func (bb) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Ba pickerUpdateCh: buffer.NewUnbounded(), requestCountMax: defaultRequestCountMax, } - b.logger = dubboLogger.GetLogger() + b.logger = dubbogoLogger.GetLogger() go b.run() b.logger.Infof("Created") return b @@ -110,7 +111,7 @@ type clusterImplBalancer struct { done *grpcsync.Event bOpts balancer.BuildOptions - logger dubboLogger.Logger + logger dubbogoLogger.Logger xdsClient client.XDSClient config *LBConfig diff --git a/xds/balancer/clusterimpl/picker.go b/xds/balancer/clusterimpl/picker.go index 95a1f7d8af..fa1e6d7937 100644 --- a/xds/balancer/clusterimpl/picker.go +++ b/xds/balancer/clusterimpl/picker.go @@ -26,6 +26,8 @@ package clusterimpl import ( orcapb "github.com/cncf/xds/go/xds/data/orca/v3" + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" @@ -36,7 +38,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client" "dubbo.apache.org/dubbo-go/v3/xds/client/load" "dubbo.apache.org/dubbo-go/v3/xds/utils/wrr" @@ -150,7 +151,7 @@ func (d *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { // be used. lIDStr, e = scw.localityID().ToString() if e != nil { - dubboLogger.Infof("failed to marshal LocalityID: %#v, loads won't be reported", scw.localityID()) + dubbogoLogger.Infof("failed to marshal LocalityID: %#v, loads won't be reported", scw.localityID()) } } diff --git a/xds/balancer/clustermanager/balancerstateaggregator.go b/xds/balancer/clustermanager/balancerstateaggregator.go index b735cc35bf..de5a957cca 100644 --- a/xds/balancer/clustermanager/balancerstateaggregator.go +++ b/xds/balancer/clustermanager/balancerstateaggregator.go @@ -29,16 +29,14 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" "google.golang.org/grpc/connectivity" ) -import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" -) - type subBalancerState struct { state balancer.State // stateToAggregate is the connectivity state used only for state @@ -55,7 +53,7 @@ func (s *subBalancerState) String() string { type balancerStateAggregator struct { cc balancer.ClientConn - logger dubboLogger.Logger + logger dubbogoLogger.Logger mu sync.Mutex // If started is false, no updates should be sent to the parent cc. A closed @@ -70,7 +68,7 @@ type balancerStateAggregator struct { idToPickerState map[string]*subBalancerState } -func newBalancerStateAggregator(cc balancer.ClientConn, logger dubboLogger.Logger) *balancerStateAggregator { +func newBalancerStateAggregator(cc balancer.ClientConn, logger dubbogoLogger.Logger) *balancerStateAggregator { return &balancerStateAggregator{ cc: cc, logger: logger, diff --git a/xds/balancer/clustermanager/clustermanager.go b/xds/balancer/clustermanager/clustermanager.go index 989da2c18d..21e154b5e3 100644 --- a/xds/balancer/clustermanager/clustermanager.go +++ b/xds/balancer/clustermanager/clustermanager.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/resolver" @@ -38,7 +40,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/utils/balancergroup" "dubbo.apache.org/dubbo-go/v3/xds/utils/hierarchy" "dubbo.apache.org/dubbo-go/v3/xds/utils/pretty" @@ -54,7 +55,7 @@ type bb struct{} func (bb) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { b := &bal{} - b.logger = dubboLogger.GetLogger() + b.logger = dubbogoLogger.GetLogger() b.stateAggregator = newBalancerStateAggregator(cc, b.logger) b.stateAggregator.start() b.bg = balancergroup.New(cc, opts, b.stateAggregator, b.logger) @@ -72,7 +73,7 @@ func (bb) ParseConfig(c json.RawMessage) (serviceconfig.LoadBalancingConfig, err } type bal struct { - logger dubboLogger.Logger + logger dubbogoLogger.Logger // TODO: make this package not dependent on xds specific code. Same as for // weighted target balancer. diff --git a/xds/balancer/clusterresolver/clusterresolver.go b/xds/balancer/clusterresolver/clusterresolver.go index ca6ee604e7..3c7fb2836f 100644 --- a/xds/balancer/clusterresolver/clusterresolver.go +++ b/xds/balancer/clusterresolver/clusterresolver.go @@ -31,6 +31,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/attributes" "google.golang.org/grpc/balancer" @@ -44,7 +46,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/balancer/priority" "dubbo.apache.org/dubbo-go/v3/xds/client" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" @@ -73,12 +74,12 @@ type bb struct{} func (bb) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { priorityBuilder := balancer.Get(priority.Name) if priorityBuilder == nil { - dubboLogger.Errorf("priority balancer is needed but not registered") + dubbogoLogger.Errorf("priority balancer is needed but not registered") return nil } priorityConfigParser, ok := priorityBuilder.(balancer.ConfigParser) if !ok { - dubboLogger.Errorf("priority balancer builder is not a config parser") + dubbogoLogger.Errorf("priority balancer builder is not a config parser") return nil } @@ -91,7 +92,7 @@ func (bb) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Bal priorityBuilder: priorityBuilder, priorityConfigParser: priorityConfigParser, } - b.logger = dubboLogger.GetLogger() + b.logger = dubbogoLogger.GetLogger() b.logger.Infof("Created") b.resourceWatcher = newResourceResolver(b) @@ -141,7 +142,7 @@ type clusterResolverBalancer struct { bOpts balancer.BuildOptions updateCh *buffer.Unbounded // Channel for updates from gRPC. resourceWatcher *resourceResolver - logger dubboLogger.Logger + logger dubbogoLogger.Logger closed *grpcsync.Event done *grpcsync.Event diff --git a/xds/balancer/clusterresolver/configbuilder.go b/xds/balancer/clusterresolver/configbuilder.go index 9c3985bbee..78be8a278d 100644 --- a/xds/balancer/clusterresolver/configbuilder.go +++ b/xds/balancer/clusterresolver/configbuilder.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer/roundrobin" "google.golang.org/grpc/balancer/weightedroundrobin" "google.golang.org/grpc/balancer/weightedtarget" @@ -38,7 +40,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/balancer/clusterimpl" "dubbo.apache.org/dubbo-go/v3/xds/balancer/priority" "dubbo.apache.org/dubbo-go/v3/xds/balancer/ringhash" @@ -277,7 +278,7 @@ func priorityLocalitiesToClusterImpl(localities []resource.Locality, priorityNam // If lb policy is ROUND_ROBIN: // - locality-picking policy is weighted_target // - endpoint-picking policy is round_robin - dubboLogger.Infof("xds lb policy is %q, building config with weighted_target + round_robin", rrName) + dubbogoLogger.Infof("xds lb policy is %q, building config with weighted_target + round_robin", rrName) // Child of weighted_target is hardcoded to round_robin. wtConfig, addrs := localitiesToWeightedTarget(localities, priorityName, rrBalancerConfig) clusterImplCfg.ChildPolicy = &internalserviceconfig.BalancerConfig{Name: weightedtarget.Name, Config: wtConfig} @@ -288,7 +289,7 @@ func priorityLocalitiesToClusterImpl(localities []resource.Locality, priorityNam // If lb policy is RIHG_HASH, will build one ring_hash policy as child. // The endpoints from all localities will be flattened to one addresses // list, and the ring_hash policy will pick endpoints from it. - dubboLogger.Infof("xds lb policy is %q, building config with ring_hash", rhName) + dubbogoLogger.Infof("xds lb policy is %q, building config with ring_hash", rhName) addrs := localitiesToRingHash(localities, priorityName) // Set child to ring_hash, note that the ring_hash config is from // xdsLBPolicy. diff --git a/xds/balancer/orca/orca.go b/xds/balancer/orca/orca.go index 4ce9ec8454..a470ccb228 100644 --- a/xds/balancer/orca/orca.go +++ b/xds/balancer/orca/orca.go @@ -27,13 +27,14 @@ package orca import ( orcapb "github.com/cncf/xds/go/xds/data/orca/v3" + "github.com/dubbogo/gost/log/logger" + "github.com/golang/protobuf/proto" "google.golang.org/grpc/metadata" ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/utils/balancerload" ) diff --git a/xds/balancer/priority/balancer.go b/xds/balancer/priority/balancer.go index 76bacd4c74..5c4c8bb0f5 100644 --- a/xds/balancer/priority/balancer.go +++ b/xds/balancer/priority/balancer.go @@ -36,6 +36,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/resolver" @@ -44,7 +46,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/utils/balancergroup" "dubbo.apache.org/dubbo-go/v3/xds/utils/buffer" "dubbo.apache.org/dubbo-go/v3/xds/utils/grpcsync" @@ -70,7 +71,7 @@ func (bb) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Ba childBalancerStateUpdate: buffer.NewUnbounded(), } - b.logger = dubboLogger.GetLogger() + b.logger = dubbogoLogger.GetLogger() b.bg = balancergroup.New(cc, bOpts, b, b.logger) b.bg.Start() go b.run() @@ -94,7 +95,7 @@ type timerWrapper struct { } type priorityBalancer struct { - logger dubboLogger.Logger + logger dubbogoLogger.Logger cc balancer.ClientConn bg *balancergroup.BalancerGroup done *grpcsync.Event diff --git a/xds/balancer/ringhash/picker.go b/xds/balancer/ringhash/picker.go index 1d62e5a13e..7611436bed 100644 --- a/xds/balancer/ringhash/picker.go +++ b/xds/balancer/ringhash/picker.go @@ -28,6 +28,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" @@ -37,16 +39,12 @@ import ( "google.golang.org/grpc/status" ) -import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" -) - type picker struct { ring *ring - logger dubboLogger.Logger + logger dubbogoLogger.Logger } -func newPicker(ring *ring, logger dubboLogger.Logger) *picker { +func newPicker(ring *ring, logger dubbogoLogger.Logger) *picker { return &picker{ring: ring, logger: logger} } diff --git a/xds/balancer/ringhash/ringhash.go b/xds/balancer/ringhash/ringhash.go index 6ee145d097..4f3a3e5350 100644 --- a/xds/balancer/ringhash/ringhash.go +++ b/xds/balancer/ringhash/ringhash.go @@ -32,6 +32,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" "google.golang.org/grpc/balancer/weightedroundrobin" @@ -44,7 +46,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/utils/pretty" ) @@ -64,7 +65,7 @@ func (bb) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Ba scStates: make(map[balancer.SubConn]*subConn), csEvltr: &connectivityStateEvaluator{}, } - b.logger = dubboLogger.GetLogger() + b.logger = dubbogoLogger.GetLogger() b.logger.Infof("Created") return b } @@ -173,7 +174,7 @@ func (sc *subConn) queueConnect() { type ringhashBalancer struct { cc balancer.ClientConn - logger dubboLogger.Logger + logger dubbogoLogger.Logger config *LBConfig @@ -231,7 +232,7 @@ func (b *ringhashBalancer) updateAddresses(addrs []resolver.Address) bool { // (like creds) will be used. sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{HealthCheckEnabled: true}) if err != nil { - dubboLogger.Warnf("base.baseBalancer: failed to create new SubConn: %v", err) + dubbogoLogger.Warnf("base.baseBalancer: failed to create new SubConn: %v", err) continue } scs := &subConn{addr: a.Addr, sc: sc} diff --git a/xds/client/authority.go b/xds/client/authority.go index e15580f6e2..a18737c11d 100644 --- a/xds/client/authority.go +++ b/xds/client/authority.go @@ -29,11 +29,12 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + _struct "github.com/golang/protobuf/ptypes/struct" ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/bootstrap" "dubbo.apache.org/dubbo-go/v3/xds/client/load" "dubbo.apache.org/dubbo-go/v3/xds/client/pubsub" @@ -72,7 +73,7 @@ func (c *clientImpl) findAuthority(n *resource.Name) (_ *authority, unref func() a, err := c.newAuthority(config) if err != nil { - dubboLogger.Errorf(`[XDS Authority] new authority failed with error = %s, please makesure you have imported + dubbogoLogger.Errorf(`[XDS Authority] new authority failed with error = %s, please makesure you have imported _ "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version/v2" _ "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version/v3"`, err) return nil, nil, fmt.Errorf("xds: failed to connect to the control plane for authority %q: %v", authority, err) diff --git a/xds/client/bootstrap/bootstrap.go b/xds/client/bootstrap/bootstrap.go index ebb76ba853..ffa02fe66d 100644 --- a/xds/client/bootstrap/bootstrap.go +++ b/xds/client/bootstrap/bootstrap.go @@ -34,6 +34,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" @@ -47,7 +49,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" internal2 "dubbo.apache.org/dubbo-go/v3/xds/internal" "dubbo.apache.org/dubbo-go/v3/xds/utils/envconfig" @@ -275,7 +276,7 @@ func bootstrapConfigFromEnvVariable() ([]byte, error) { // // Note that even if the content is invalid, we don't failover to the // file content env variable. - dubboLogger.Debugf("xds: using bootstrap file with name %q", fName) + dubbogoLogger.Debugf("xds: using bootstrap file with name %q", fName) return bootstrapFileReadFunc(fName) } @@ -305,7 +306,7 @@ func NewConfig() (*Config, error) { if err != nil { return nil, fmt.Errorf("xds: Failed to read bootstrap config: %v", err) } - dubboLogger.Debugf("Bootstrap content: %s", data) + dubbogoLogger.Debugf("Bootstrap content: %s", data) return NewConfigFromContents(data) } @@ -374,7 +375,7 @@ func NewConfigFromContents(data []byte) (*Config, error) { } case "client_default_listener_resource_name_template": if !envconfig.XDSFederation { - dubboLogger.Warnf("xds: bootstrap field %v is not support when Federation is disabled", k) + dubbogoLogger.Warnf("xds: bootstrap field %v is not support when Federation is disabled", k) continue } if err := json.Unmarshal(v, &config.ClientDefaultListenerResourceNameTemplate); err != nil { @@ -382,14 +383,14 @@ func NewConfigFromContents(data []byte) (*Config, error) { } case "authorities": if !envconfig.XDSFederation { - dubboLogger.Warnf("xds: bootstrap field %v is not support when Federation is disabled", k) + dubbogoLogger.Warnf("xds: bootstrap field %v is not support when Federation is disabled", k) continue } if err := json.Unmarshal(v, &config.Authorities); err != nil { return nil, fmt.Errorf("xds: json.Unmarshal(%v) for field %q failed during bootstrap: %v", string(v), k, err) } default: - dubboLogger.Warnf("Bootstrap content has unknown field: %s", k) + dubbogoLogger.Warnf("Bootstrap content has unknown field: %s", k) } // Do not fail the xDS bootstrap when an unknown field is seen. This can // happen when an older version client reads a newer version bootstrap @@ -426,7 +427,7 @@ func NewConfigFromContents(data []byte) (*Config, error) { if err := config.updateNodeProto(node); err != nil { return nil, err } - dubboLogger.Infof("Bootstrap config for creating xds-client: %v", pretty.ToJSON(config)) + dubbogoLogger.Infof("Bootstrap config for creating xds-client: %v", pretty.ToJSON(config)) return config, nil } diff --git a/xds/client/client.go b/xds/client/client.go index f1de41027f..2821ba8f5f 100644 --- a/xds/client/client.go +++ b/xds/client/client.go @@ -32,11 +32,12 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + _struct "github.com/golang/protobuf/ptypes/struct" ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/bootstrap" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" "dubbo.apache.org/dubbo-go/v3/xds/utils/grpcsync" @@ -75,7 +76,7 @@ type clientImpl struct { // never both. idleAuthorities *cache.TimeoutCache - logger dubboLogger.Logger + logger dubbogoLogger.Logger watchExpiryTimeout time.Duration } @@ -96,7 +97,7 @@ func newWithConfig(config *bootstrap.Config, watchExpiryTimeout time.Duration, i } }() - c.logger = dubboLogger.GetLogger() + c.logger = dubbogoLogger.GetLogger() c.logger.Infof("Created ClientConn to xDS management server: %s", config.XDSServer) c.logger.Infof("Created") diff --git a/xds/client/controller.go b/xds/client/controller.go index 3af5ae408b..79019c3529 100644 --- a/xds/client/controller.go +++ b/xds/client/controller.go @@ -24,11 +24,12 @@ package client import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + _struct "github.com/golang/protobuf/ptypes/struct" ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/bootstrap" "dubbo.apache.org/dubbo-go/v3/xds/client/controller" "dubbo.apache.org/dubbo-go/v3/xds/client/load" @@ -44,6 +45,6 @@ type controllerInterface interface { Close() } -var newController = func(config *bootstrap.ServerConfig, pubsub *pubsub.Pubsub, validator resource.UpdateValidatorFunc, logger dubboLogger.Logger) (controllerInterface, error) { +var newController = func(config *bootstrap.ServerConfig, pubsub *pubsub.Pubsub, validator resource.UpdateValidatorFunc, logger dubbogoLogger.Logger) (controllerInterface, error) { return controller.New(config, pubsub, validator, logger) } diff --git a/xds/client/controller/controller.go b/xds/client/controller/controller.go index 6f45b94a3d..f112f1fa5a 100644 --- a/xds/client/controller/controller.go +++ b/xds/client/controller/controller.go @@ -38,6 +38,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" _struct "github.com/golang/protobuf/ptypes/struct" @@ -47,7 +49,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/bootstrap" "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version" "dubbo.apache.org/dubbo-go/v3/xds/client/pubsub" @@ -67,7 +68,7 @@ type Controller struct { config *bootstrap.ServerConfig updateHandler pubsub.UpdateHandler updateValidator resource.UpdateValidatorFunc - logger dubboLogger.Logger + logger dubbogoLogger.Logger cc *grpc.ClientConn // Connection to the management server. vClient version.MetadataWrappedVersionClient @@ -104,7 +105,7 @@ type Controller struct { } // New creates a new controller. -func New(config *bootstrap.ServerConfig, updateHandler pubsub.UpdateHandler, validator resource.UpdateValidatorFunc, logger dubboLogger.Logger) (_ *Controller, retErr error) { +func New(config *bootstrap.ServerConfig, updateHandler pubsub.UpdateHandler, validator resource.UpdateValidatorFunc, logger dubbogoLogger.Logger) (_ *Controller, retErr error) { switch { case config == nil: return nil, errors.New("xds: no xds_server provided") diff --git a/xds/client/controller/version/v2/client.go b/xds/client/controller/version/v2/client.go index db17af0554..4eac9ba44b 100644 --- a/xds/client/controller/version/v2/client.go +++ b/xds/client/controller/version/v2/client.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v2xdspb "github.com/envoyproxy/go-control-plane/envoy/api/v2" v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" v2adsgrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v2" @@ -46,7 +48,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" controllerversion "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" resourceversion "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" @@ -71,7 +72,7 @@ func newClient(opts controllerversion.BuildOptions) (controllerversion.MetadataW if !ok { return nil, fmt.Errorf("xds: unsupported Node proto type: %T, want %T", opts.NodeProto, (*v2corepb.Node)(nil)) } - v2c := &client{nodeProto: nodeProto, logger: dubboLogger.GetLogger()} + v2c := &client{nodeProto: nodeProto, logger: dubbogoLogger.GetLogger()} return v2c, nil } @@ -82,7 +83,7 @@ type adsStream v2adsgrpc.AggregatedDiscoveryService_StreamAggregatedResourcesCli // are multiplexed. type client struct { nodeProto *v2corepb.Node - logger dubboLogger.Logger + logger dubbogoLogger.Logger } // SetMetadata update client metadata diff --git a/xds/client/controller/version/v3/client.go b/xds/client/controller/version/v3/client.go index b20a409059..ada3e1de3e 100644 --- a/xds/client/controller/version/v3/client.go +++ b/xds/client/controller/version/v3/client.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3adsgrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" @@ -46,7 +48,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" controllerversion "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" resourceversion "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" @@ -72,7 +73,7 @@ func newClient(opts controllerversion.BuildOptions) (controllerversion.MetadataW return nil, fmt.Errorf("xds: unsupported Node proto type: %T, want %T", opts.NodeProto, v3corepb.Node{}) } v3c := &client{ - nodeProto: nodeProto, logger: dubboLogger.GetLogger(), + nodeProto: nodeProto, logger: dubbogoLogger.GetLogger(), } return v3c, nil } @@ -84,7 +85,7 @@ type adsStream v3adsgrpc.AggregatedDiscoveryService_StreamAggregatedResourcesCli // are multiplexed. type client struct { nodeProto *v3corepb.Node - logger dubboLogger.Logger + logger dubbogoLogger.Logger } func (v3c *client) NewStream(ctx context.Context, cc *grpc.ClientConn) (grpc.ClientStream, error) { diff --git a/xds/client/controller/version/version.go b/xds/client/controller/version/version.go index 43262668a7..3487b8f424 100644 --- a/xds/client/controller/version/version.go +++ b/xds/client/controller/version/version.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "github.com/golang/protobuf/proto" _struct "github.com/golang/protobuf/ptypes/struct" @@ -39,7 +41,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/load" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" @@ -77,7 +78,7 @@ type BuildOptions struct { // // streams. // Backoff func(int) time.Duration // Logger provides enhanced logging capabilities. - Logger dubboLogger.Logger + Logger dubbogoLogger.Logger } // LoadReportingOptions contains configuration knobs for reporting load data. diff --git a/xds/client/pubsub/pubsub.go b/xds/client/pubsub/pubsub.go index 70deddc3bf..ea25682729 100644 --- a/xds/client/pubsub/pubsub.go +++ b/xds/client/pubsub/pubsub.go @@ -34,7 +34,10 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" + dubbogoLogger "github.com/dubbogo/gost/log/logger" +) + +import ( "dubbo.apache.org/dubbo-go/v3/xds/client/resource" "dubbo.apache.org/dubbo-go/v3/xds/utils/buffer" "dubbo.apache.org/dubbo-go/v3/xds/utils/grpcsync" @@ -47,7 +50,7 @@ import ( // any time. type Pubsub struct { done *grpcsync.Event - logger dubboLogger.Logger + logger dubbogoLogger.Logger watchExpiryTimeout time.Duration updateCh *buffer.Unbounded // chan *watcherInfoWithUpdate @@ -68,7 +71,7 @@ type Pubsub struct { } // New creates a new Pubsub. -func New(watchExpiryTimeout time.Duration, logger dubboLogger.Logger) *Pubsub { +func New(watchExpiryTimeout time.Duration, logger dubbogoLogger.Logger) *Pubsub { pb := &Pubsub{ done: grpcsync.NewEvent(), logger: logger, diff --git a/xds/client/resource/filter_chain.go b/xds/client/resource/filter_chain.go index afcb7c5021..e59e2386cc 100644 --- a/xds/client/resource/filter_chain.go +++ b/xds/client/resource/filter_chain.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3" @@ -39,7 +41,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" "dubbo.apache.org/dubbo-go/v3/xds/httpfilter" "dubbo.apache.org/dubbo-go/v3/xds/utils/envconfig" @@ -189,7 +190,7 @@ const ( // 7. Source IP address. // 8. Source port. type FilterChainManager struct { - logger dubboLogger.Logger + logger dubbogoLogger.Logger // Destination prefix is the first match criteria that we support. // Therefore, this multi-stage map is indexed on destination prefixes // specified in the match criteria. @@ -260,7 +261,7 @@ type sourcePrefixEntry struct { // // This function is only exported so that tests outside of this package can // create a FilterChainManager. -func NewFilterChainManager(lis *v3listenerpb.Listener, logger dubboLogger.Logger) (*FilterChainManager, error) { +func NewFilterChainManager(lis *v3listenerpb.Listener, logger dubbogoLogger.Logger) (*FilterChainManager, error) { // Parse all the filter chains and build the internal data structures. fci := &FilterChainManager{ logger: logger, diff --git a/xds/client/resource/unmarshal.go b/xds/client/resource/unmarshal.go index b643651b51..64da2c1f08 100644 --- a/xds/client/resource/unmarshal.go +++ b/xds/client/resource/unmarshal.go @@ -33,11 +33,9 @@ import ( ) import ( - "google.golang.org/protobuf/types/known/anypb" -) + dubbogoLogger "github.com/dubbogo/gost/log/logger" -import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" + "google.golang.org/protobuf/types/known/anypb" ) // UnmarshalOptions wraps the input parameters for `UnmarshalXxx` functions. @@ -47,7 +45,7 @@ type UnmarshalOptions struct { // Resources are the xDS resources resources in the received response. Resources []*anypb.Any // Logger is the prefix logger to be used during unmarshaling. - Logger dubboLogger.Logger + Logger dubbogoLogger.Logger // UpdateValidator is a post unmarshal validation check provided by the // upper layer. UpdateValidator UpdateValidatorFunc diff --git a/xds/client/resource/unmarshal_cds.go b/xds/client/resource/unmarshal_cds.go index aa909d6087..8e8d7d6f25 100644 --- a/xds/client/resource/unmarshal_cds.go +++ b/xds/client/resource/unmarshal_cds.go @@ -31,6 +31,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3aggregateclusterpb "github.com/envoyproxy/go-control-plane/envoy/extensions/clusters/aggregate/v3" @@ -42,7 +44,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" "dubbo.apache.org/dubbo-go/v3/xds/utils/envconfig" "dubbo.apache.org/dubbo-go/v3/xds/utils/matcher" @@ -62,7 +63,7 @@ func UnmarshalCluster(opts *UnmarshalOptions) (map[string]ClusterUpdateErrTuple, return update, md, err } -func unmarshalClusterResource(r *anypb.Any, f UpdateValidatorFunc, logger dubboLogger.Logger) (string, ClusterUpdate, error) { +func unmarshalClusterResource(r *anypb.Any, f UpdateValidatorFunc, logger dubbogoLogger.Logger) (string, ClusterUpdate, error) { if !IsClusterResource(r.GetTypeUrl()) { return "", ClusterUpdate{}, fmt.Errorf("unexpected resource type: %q ", r.GetTypeUrl()) } @@ -71,7 +72,7 @@ func unmarshalClusterResource(r *anypb.Any, f UpdateValidatorFunc, logger dubboL if err := proto.Unmarshal(r.GetValue(), cluster); err != nil { return "", ClusterUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err) } - dubboLogger.Debugf("Resource with name: %v, type: %T, contains: %v", cluster.GetName(), cluster, pretty.ToJSON(cluster)) + dubbogoLogger.Debugf("Resource with name: %v, type: %T, contains: %v", cluster.GetName(), cluster, pretty.ToJSON(cluster)) cu, err := validateClusterAndConstructClusterUpdate(cluster) if err != nil { return cluster.GetName(), ClusterUpdate{}, err diff --git a/xds/client/resource/unmarshal_eds.go b/xds/client/resource/unmarshal_eds.go index 23132e9032..07111a9606 100644 --- a/xds/client/resource/unmarshal_eds.go +++ b/xds/client/resource/unmarshal_eds.go @@ -30,6 +30,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" @@ -40,7 +42,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/utils/pretty" ) @@ -53,7 +54,7 @@ func UnmarshalEndpoints(opts *UnmarshalOptions) (map[string]EndpointsUpdateErrTu return update, md, err } -func unmarshalEndpointsResource(r *anypb.Any, logger dubboLogger.Logger) (string, EndpointsUpdate, error) { +func unmarshalEndpointsResource(r *anypb.Any, logger dubbogoLogger.Logger) (string, EndpointsUpdate, error) { if !IsEndpointsResource(r.GetTypeUrl()) { return "", EndpointsUpdate{}, fmt.Errorf("unexpected resource type: %q ", r.GetTypeUrl()) } @@ -62,7 +63,7 @@ func unmarshalEndpointsResource(r *anypb.Any, logger dubboLogger.Logger) (string if err := proto.Unmarshal(r.GetValue(), cla); err != nil { return "", EndpointsUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err) } - dubboLogger.Debugf("Resource with name: %v, type: %T, contains: %v", cla.GetClusterName(), cla, pretty.ToJSON(cla)) + dubbogoLogger.Debugf("Resource with name: %v, type: %T, contains: %v", cla.GetClusterName(), cla, pretty.ToJSON(cla)) u, err := parseEDSRespProto(cla) if err != nil { diff --git a/xds/client/resource/unmarshal_lds.go b/xds/client/resource/unmarshal_lds.go index 011b4593fc..b2efbac815 100644 --- a/xds/client/resource/unmarshal_lds.go +++ b/xds/client/resource/unmarshal_lds.go @@ -34,6 +34,8 @@ import ( v3cncftypepb "github.com/cncf/xds/go/xds/type/v3" + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" @@ -45,7 +47,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" "dubbo.apache.org/dubbo-go/v3/xds/httpfilter" "dubbo.apache.org/dubbo-go/v3/xds/utils/pretty" @@ -60,7 +61,7 @@ func UnmarshalListener(opts *UnmarshalOptions) (map[string]ListenerUpdateErrTupl return update, md, err } -func unmarshalListenerResource(r *anypb.Any, f UpdateValidatorFunc, logger dubboLogger.Logger) (string, ListenerUpdate, error) { +func unmarshalListenerResource(r *anypb.Any, f UpdateValidatorFunc, logger dubbogoLogger.Logger) (string, ListenerUpdate, error) { if !IsListenerResource(r.GetTypeUrl()) { return "", ListenerUpdate{}, fmt.Errorf("unexpected resource type: %q ", r.GetTypeUrl()) } @@ -70,7 +71,7 @@ func unmarshalListenerResource(r *anypb.Any, f UpdateValidatorFunc, logger dubbo if err := proto.Unmarshal(r.GetValue(), lis); err != nil { return "", ListenerUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err) } - dubboLogger.Debugf("Resource with name: %v, type: %T, contains: %v", lis.GetName(), lis, pretty.ToJSON(lis)) + dubbogoLogger.Debugf("Resource with name: %v, type: %T, contains: %v", lis.GetName(), lis, pretty.ToJSON(lis)) lu, err := processListener(lis, logger, v2) if err != nil { @@ -85,7 +86,7 @@ func unmarshalListenerResource(r *anypb.Any, f UpdateValidatorFunc, logger dubbo return lis.GetName(), *lu, nil } -func processListener(lis *v3listenerpb.Listener, logger dubboLogger.Logger, v2 bool) (*ListenerUpdate, error) { +func processListener(lis *v3listenerpb.Listener, logger dubbogoLogger.Logger, v2 bool) (*ListenerUpdate, error) { if lis.GetApiListener() != nil { return processClientSideListener(lis, logger, v2) } @@ -94,7 +95,7 @@ func processListener(lis *v3listenerpb.Listener, logger dubboLogger.Logger, v2 b // processClientSideListener checks if the provided Listener proto meets // the expected criteria. If so, it returns a non-empty routeConfigName. -func processClientSideListener(lis *v3listenerpb.Listener, logger dubboLogger.Logger, v2 bool) (*ListenerUpdate, error) { +func processClientSideListener(lis *v3listenerpb.Listener, logger dubbogoLogger.Logger, v2 bool) (*ListenerUpdate, error) { update := &ListenerUpdate{} apiLisAny := lis.GetApiListener().GetApiListener() @@ -281,7 +282,7 @@ func processHTTPFilters(filters []*v3httppb.HttpFilter, server bool) ([]HTTPFilt return ret, nil } -func processServerSideListener(lis *v3listenerpb.Listener, logger dubboLogger.Logger) (*ListenerUpdate, error) { +func processServerSideListener(lis *v3listenerpb.Listener, logger dubbogoLogger.Logger) (*ListenerUpdate, error) { if n := len(lis.ListenerFilters); n != 0 { return nil, fmt.Errorf("unsupported field 'listener_filters' contains %d entries", n) } diff --git a/xds/client/resource/unmarshal_rds.go b/xds/client/resource/unmarshal_rds.go index 3cf346da73..9b8717ae4c 100644 --- a/xds/client/resource/unmarshal_rds.go +++ b/xds/client/resource/unmarshal_rds.go @@ -31,6 +31,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" @@ -42,7 +44,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/resource/version" "dubbo.apache.org/dubbo-go/v3/xds/clusterspecifier" "dubbo.apache.org/dubbo-go/v3/xds/utils/envconfig" @@ -59,7 +60,7 @@ func UnmarshalRouteConfig(opts *UnmarshalOptions) (map[string]RouteConfigUpdateE return update, md, err } -func unmarshalRouteConfigResource(r *anypb.Any, logger dubboLogger.Logger) (string, RouteConfigUpdate, error) { +func unmarshalRouteConfigResource(r *anypb.Any, logger dubbogoLogger.Logger) (string, RouteConfigUpdate, error) { if !IsRouteConfigResource(r.GetTypeUrl()) { return "", RouteConfigUpdate{}, fmt.Errorf("unexpected resource type: %q ", r.GetTypeUrl()) } @@ -67,7 +68,7 @@ func unmarshalRouteConfigResource(r *anypb.Any, logger dubboLogger.Logger) (stri if err := proto.Unmarshal(r.GetValue(), rc); err != nil { return "", RouteConfigUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err) } - dubboLogger.Debugf("Resource with name: %v, type: %T, contains: %v.", rc.GetName(), rc, pretty.ToJSON(rc)) + dubbogoLogger.Debugf("Resource with name: %v, type: %T, contains: %v.", rc.GetName(), rc, pretty.ToJSON(rc)) // TODO: Pass version.TransportAPI instead of relying upon the type URL v2 := r.GetTypeUrl() == version.V2RouteConfigURL @@ -95,7 +96,7 @@ func unmarshalRouteConfigResource(r *anypb.Any, logger dubboLogger.Logger) (stri // field must be empty and whose route field must be set. Inside that route // message, the cluster field will contain the clusterName or weighted clusters // we are looking for. -func generateRDSUpdateFromRouteConfiguration(rc *v3routepb.RouteConfiguration, logger dubboLogger.Logger, v2 bool) (RouteConfigUpdate, error) { +func generateRDSUpdateFromRouteConfiguration(rc *v3routepb.RouteConfiguration, logger dubbogoLogger.Logger, v2 bool) (RouteConfigUpdate, error) { vhs := make([]*VirtualHost, 0, len(rc.GetVirtualHosts())) csps := make(map[string]clusterspecifier.BalancerConfig) if envconfig.XDSRLS { @@ -230,7 +231,7 @@ func generateRetryConfig(rp *v3routepb.RetryPolicy) (*RetryConfig, error) { return cfg, nil } -func routesProtoToSlice(routes []*v3routepb.Route, csps map[string]clusterspecifier.BalancerConfig, logger dubboLogger.Logger, v2 bool) ([]*Route, map[string]bool, error) { +func routesProtoToSlice(routes []*v3routepb.Route, csps map[string]clusterspecifier.BalancerConfig, logger dubbogoLogger.Logger, v2 bool) ([]*Route, map[string]bool, error) { var routesRet []*Route var cspNames = make(map[string]bool) for _, r := range routes { @@ -421,7 +422,7 @@ func routesProtoToSlice(routes []*v3routepb.Route, csps map[string]clusterspecif return routesRet, cspNames, nil } -func hashPoliciesProtoToSlice(policies []*v3routepb.RouteAction_HashPolicy, logger dubboLogger.Logger) ([]*HashPolicy, error) { +func hashPoliciesProtoToSlice(policies []*v3routepb.RouteAction_HashPolicy, logger dubbogoLogger.Logger) ([]*HashPolicy, error) { var hashPoliciesRet []*HashPolicy for _, p := range policies { policy := HashPolicy{Terminal: p.Terminal} diff --git a/xds/csds/csds.go b/xds/csds/csds.go index f5172a3975..0f0424f2ab 100644 --- a/xds/csds/csds.go +++ b/xds/csds/csds.go @@ -34,6 +34,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + v3adminpb "github.com/envoyproxy/go-control-plane/envoy/admin/v3" v2corepb "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" @@ -50,13 +52,13 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client" - _ "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version/v2" // Register v2 xds_client. - _ "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version/v3" // Register v3 xds_client. + _ "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version/v2" + _ "dubbo.apache.org/dubbo-go/v3/xds/client/controller/version/v3" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" ) +// Register v3 xds_client. var ( newXDSClient = func() client.XDSClient { c, err := client.New() diff --git a/xds/resolver/watch_service.go b/xds/resolver/watch_service.go index 7b275f4c2b..6abd5277c5 100644 --- a/xds/resolver/watch_service.go +++ b/xds/resolver/watch_service.go @@ -30,7 +30,10 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" + dubbogoLogger "github.com/dubbogo/gost/log/logger" +) + +import ( "dubbo.apache.org/dubbo-go/v3/xds/client" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" "dubbo.apache.org/dubbo-go/v3/xds/clusterspecifier" @@ -65,7 +68,7 @@ type ldsConfig struct { // Note that during race (e.g. an xDS response is received while the user is // calling cancel()), there's a small window where the callback can be called // after the watcher is canceled. The caller needs to handle this case. -func watchService(c client.XDSClient, serviceName string, cb func(serviceUpdate, error), logger dubboLogger.Logger) (cancel func()) { +func watchService(c client.XDSClient, serviceName string, cb func(serviceUpdate, error), logger dubbogoLogger.Logger) (cancel func()) { w := &serviceUpdateWatcher{ logger: logger, c: c, @@ -80,7 +83,7 @@ func watchService(c client.XDSClient, serviceName string, cb func(serviceUpdate, // serviceUpdateWatcher handles LDS and RDS response, and calls the service // callback at the right time. type serviceUpdateWatcher struct { - logger dubboLogger.Logger + logger dubbogoLogger.Logger c client.XDSClient serviceName string ldsCancel func() diff --git a/xds/resolver/xds_resolver.go b/xds/resolver/xds_resolver.go index 9457c62129..6e9e5394f4 100644 --- a/xds/resolver/xds_resolver.go +++ b/xds/resolver/xds_resolver.go @@ -32,13 +32,14 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/credentials" "google.golang.org/grpc/resolver" ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client" "dubbo.apache.org/dubbo-go/v3/xds/client/bootstrap" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" @@ -88,7 +89,7 @@ func (b *xdsResolverBuilder) Build(t resolver.Target, cc resolver.ClientConn, op r.Close() } }() - r.logger = dubboLogger.GetLogger() + r.logger = dubbogoLogger.GetLogger() r.logger.Infof("Creating resolver for target: %+v", t) newXDSClient := newXDSClient @@ -181,7 +182,7 @@ type xdsResolver struct { cc resolver.ClientConn closed *grpcsync.Event - logger dubboLogger.Logger + logger dubbogoLogger.Logger // The underlying xdsClient which performs all xDS requests and responses. client client.XDSClient diff --git a/xds/server/listener_wrapper.go b/xds/server/listener_wrapper.go index cf3d12f92b..cea10fcd70 100644 --- a/xds/server/listener_wrapper.go +++ b/xds/server/listener_wrapper.go @@ -36,6 +36,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/backoff" "google.golang.org/grpc/connectivity" @@ -44,7 +46,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/xds/client/bootstrap" "dubbo.apache.org/dubbo-go/v3/xds/client/resource" internalbackoff "dubbo.apache.org/dubbo-go/v3/xds/utils/backoff" @@ -124,7 +125,7 @@ func NewListenerWrapper(params ListenerWrapperParams) (net.Listener, <-chan stru ldsUpdateCh: make(chan ldsUpdateWithError, 1), rdsUpdateCh: make(chan rdsHandlerUpdate, 1), } - lw.logger = dubboLogger.GetLogger() + lw.logger = dubbogoLogger.GetLogger() // Serve() verifies that Addr() returns a valid TCPAddr. So, it is safe to // ignore the error from SplitHostPort(). @@ -153,7 +154,7 @@ type ldsUpdateWithError struct { // particular invocation of Serve(). type listenerWrapper struct { net.Listener - logger dubboLogger.Logger + logger dubbogoLogger.Logger name string xdsCredsInUse bool diff --git a/xds/utils/balancergroup/balancergroup.go b/xds/utils/balancergroup/balancergroup.go index 3f11e9b4f1..5b863a96ad 100644 --- a/xds/utils/balancergroup/balancergroup.go +++ b/xds/utils/balancergroup/balancergroup.go @@ -32,6 +32,8 @@ import ( ) import ( + dubbogoLogger "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" @@ -40,7 +42,6 @@ import ( ) import ( - dubboLogger "dubbo.apache.org/dubbo-go/v3/common/logger" cache "dubbo.apache.org/dubbo-go/v3/xds/utils/xds_cache" ) @@ -206,7 +207,7 @@ func (sbc *subBalancerWrapper) stopBalancer() { type BalancerGroup struct { cc balancer.ClientConn buildOpts balancer.BuildOptions - logger dubboLogger.Logger + logger dubbogoLogger.Logger // stateAggregator is where the state/picker updates will be sent to. It's // provided by the parent balancer, to build a picker with all the @@ -261,7 +262,7 @@ var DefaultSubBalancerCloseTimeout = 15 * time.Minute // New creates a new BalancerGroup. Note that the BalancerGroup // needs to be started to work. -func New(cc balancer.ClientConn, bOpts balancer.BuildOptions, stateAggregator BalancerStateAggregator, logger dubboLogger.Logger) *BalancerGroup { +func New(cc balancer.ClientConn, bOpts balancer.BuildOptions, stateAggregator BalancerStateAggregator, logger dubbogoLogger.Logger) *BalancerGroup { return &BalancerGroup{ cc: cc, buildOpts: bOpts, diff --git a/xds/utils/grpclog/grpclog.go b/xds/utils/grpclog/grpclog.go index aa7a2d37f8..1b7907edec 100644 --- a/xds/utils/grpclog/grpclog.go +++ b/xds/utils/grpclog/grpclog.go @@ -29,7 +29,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" + "github.com/dubbogo/gost/log/logger" ) // Logger is the logger used for the non-depth log functions. diff --git a/xds/utils/serviceconfig/serviceconfig.go b/xds/utils/serviceconfig/serviceconfig.go index a9115f5710..1384d51cd9 100644 --- a/xds/utils/serviceconfig/serviceconfig.go +++ b/xds/utils/serviceconfig/serviceconfig.go @@ -31,6 +31,8 @@ import ( ) import ( + "github.com/dubbogo/gost/log/logger" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" @@ -38,10 +40,6 @@ import ( externalserviceconfig "google.golang.org/grpc/serviceconfig" ) -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" -) - // BalancerConfig wraps the name and config associated with one load balancing // policy. It corresponds to a single entry of the loadBalancingConfig field // from ServiceConfig.