You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zt...@apache.org on 2022/05/10 01:34:30 UTC
[dubbo-go-pixiu] branch develop updated: Lds basic (#417)
This is an automated email from the ASF dual-hosted git repository.
ztelur pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git
The following commit(s) were added to refs/heads/develop by this push:
new bcc678de Lds basic (#417)
bcc678de is described below
commit bcc678deae99b6c22848b704b5d970dd37f4baba
Author: Mark4z <36...@users.noreply.github.com>
AuthorDate: Tue May 10 09:34:25 2022 +0800
Lds basic (#417)
* basic
* simple reload
* simple reload
* simple reload
* simple reload
* simple reload
* http2_listener.go
* fix ut
* dubbo/triple done
* dubbo/triple done
* ut for lds
* switch to github.com/dubbo-go-pixiu/pixiu-api
* imports-formatter
* fix ci
* fix ci
* mod fmt
* mod fmt
Co-authored-by: mark4z <ma...@gmail.com>
---
cmd/pixiu/pixiu.go | 2 +-
go.mod | 2 +-
go.sum | 4 +-
pkg/adapter/dubboregistry/common/common.go | 4 +-
.../registry/base/baseregistry_test.go | 2 +-
.../registry/nacos/interface_listener.go | 1 +
.../registry/nacos/service_listener.go | 4 +-
pkg/adapter/dubboregistry/registry/registry.go | 4 +-
pkg/adapter/dubboregistry/registry/util.go | 3 +-
.../zookeeper/application_service_listener.go | 3 +-
.../registry/zookeeper/interface_listener.go | 1 +
.../registry/zookeeper/registry_test.go | 4 +-
.../registry/zookeeper/service_listener.go | 2 +-
pkg/adapter/dubboregistry/registrycenter.go | 4 +-
.../zookeeper/application_listener.go | 1 +
.../servicediscovery/zookeeper/service_listener.go | 1 +
pkg/client/dubbo/default.go | 2 +-
pkg/client/dubbo/dubbo.go | 2 +-
pkg/client/dubbo/dubbo_test.go | 2 +-
pkg/client/dubbo/mapper.go | 2 +-
pkg/client/dubbo/mapper_test.go | 2 +-
pkg/client/http/http_test.go | 2 +-
pkg/client/http/mapper.go | 2 +-
pkg/client/http/mapper_test.go | 2 +-
pkg/client/mapper.go | 2 +-
pkg/client/request.go | 4 +-
pkg/common/extension/filter/filter.go | 3 +-
pkg/common/grpc/manager.go | 4 +-
pkg/common/http/manager.go | 4 +-
pkg/common/http/manager_test.go | 2 +-
pkg/common/mock/router.go | 4 +-
pkg/config/api_config.go | 2 +-
pkg/config/xds/cds.go | 28 ++--
pkg/config/xds/cds_test.go | 18 +--
pkg/config/xds/lds.go | 51 ++++++--
pkg/config/xds/lds_test.go | 144 ++++++++++++++++++++-
pkg/config/xds/xds.go | 4 +-
pkg/config/xds/xds_test.go | 2 +-
pkg/context/http/context.go | 2 +-
pkg/filter/header/header_test.go | 4 +-
pkg/filter/http/apiconfig/api/discovery_service.go | 4 +-
.../http/apiconfig/api/discovery_service_test.go | 2 +-
pkg/filter/http/apiconfig/api_config.go | 4 +-
pkg/filter/http/remote/call.go | 4 +-
pkg/filter/network/dubboproxy/manager.go | 2 +-
pkg/filter/network/dubboproxy/plugin.go | 4 +-
pkg/filter/network/grpcconnectionmanager/plugin.go | 4 +-
pkg/filter/network/httpconnectionmanager/plugin.go | 4 +-
pkg/filter/seata/filter.go | 1 +
.../circuitbreaker/circuit_breaker_test.go | 1 +
pkg/filter/sentinel/ratelimit/config.go | 4 +-
pkg/filterchain/network_filter_chain.go | 4 +-
pkg/listener/http/http_listener.go | 18 ++-
pkg/listener/http2/http2_listener.go | 26 +++-
pkg/listener/listener.go | 7 +
pkg/listener/tcp/tcp_listener.go | 19 ++-
pkg/listener/triple/triple_listener.go | 19 ++-
pkg/model/base.go | 2 +-
pkg/pool/pool.go | 2 +-
pkg/remote/zookeeper/client.go | 1 +
pkg/router/api.go | 2 +-
pkg/router/api_test.go | 4 +-
pkg/router/route.go | 4 +-
pkg/router/route_test.go | 4 +-
pkg/server/api_config_manager.go | 4 +-
pkg/server/controls/controls.go | 5 +-
pkg/server/controls/mocks/mocks.go | 6 +-
pkg/server/dynamic_resource_manager.go | 2 +-
pkg/server/listener_manager.go | 137 +++++++++++++++-----
pkg/server/pixiu_start.go | 8 +-
samples/dubbogo/multi/server/app/student.go | 1 +
samples/dubbogo/multi/server/app/teacher.go | 1 +
.../dubbogo/simple/benchmark/server/app/user.go | 1 +
samples/dubbogo/simple/jaeger/server/app/user.go | 1 +
samples/dubbogo/simple/mix/server/app/user.go | 1 +
samples/dubbogo/simple/proxy/server/app/user.go | 1 +
samples/dubbogo/simple/query/server/app/user.go | 1 +
samples/dubbogo/simple/resolve/server/app/user.go | 1 +
.../simple/triple/protobuf/api/helloworld.pb.go | 2 +-
.../dubbogo/simple/triple/server/app/greeter.go | 5 +-
.../triple/server/protobuf/api/samples_api.pb.go | 2 +-
samples/dubbogo/simple/uri/server/app/user.go | 1 +
samples/grpc/pixiu/conf.yaml | 1 -
samples/grpc/test/pixiu_test.go | 1 +
samples/xds/local-control-panel/server/app/go.sum | 2 +-
samples/xds/local-control-panel/server/app/main.go | 5 +-
.../server/app/resoruce_pixiu2.go | 6 +-
.../server/app/resource_pixiu.go | 15 ++-
.../xds/local-control-panel/server/app/server.go | 10 +-
89 files changed, 535 insertions(+), 167 deletions(-)
diff --git a/cmd/pixiu/pixiu.go b/cmd/pixiu/pixiu.go
index f71a2cb9..76fe57b5 100644
--- a/cmd/pixiu/pixiu.go
+++ b/cmd/pixiu/pixiu.go
@@ -26,12 +26,12 @@ import (
)
import (
- pxruntime "github.com/apache/dubbo-go-pixiu/pkg/common/runtime"
"github.com/spf13/cobra"
)
import (
"github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ pxruntime "github.com/apache/dubbo-go-pixiu/pkg/common/runtime"
"github.com/apache/dubbo-go-pixiu/pkg/config"
"github.com/apache/dubbo-go-pixiu/pkg/logger"
"github.com/apache/dubbo-go-pixiu/pkg/model"
diff --git a/go.mod b/go.mod
index fbdba3b4..090ea8da 100644
--- a/go.mod
+++ b/go.mod
@@ -11,7 +11,7 @@ require (
github.com/apache/dubbo-go-hessian2 v1.11.0
github.com/cch123/supermonkey v1.0.1
github.com/creasty/defaults v1.5.2
- github.com/dubbogo/dubbo-go-pixiu-filter v0.1.5
+ github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5
github.com/dubbogo/gost v1.11.22
github.com/dubbogo/grpc-go v1.42.7
diff --git a/go.sum b/go.sum
index 99e062ef..228f963a 100644
--- a/go.sum
+++ b/go.sum
@@ -198,8 +198,8 @@ github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zA
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
-github.com/dubbogo/dubbo-go-pixiu-filter v0.1.5 h1:qwzUNqWdLjE3+in49/Ny1Vjfzrztzd3JcxdUenDe610=
-github.com/dubbogo/dubbo-go-pixiu-filter v0.1.5/go.mod h1:sZSi0hyl9rquVwHZQxNa8ARs85/gQAwzjYgbxFLP4yY=
+github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a h1:M4EqGQRk3jO+k50Wa9EtrOoCYlU/kXzbpYxVo4s4Wi0=
+github.com/dubbo-go-pixiu/pixiu-api v0.1.6-0.20220427143451-c0a68bf5b29a/go.mod h1:1l+6pDTdEHwCyyyJmfckOAdGp6f5PZ33ZVMgxso9q/U=
github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 h1:XoR8SSVziXe698dt4uZYDfsmHpKLemqAgFyndQsq5Kw=
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
diff --git a/pkg/adapter/dubboregistry/common/common.go b/pkg/adapter/dubboregistry/common/common.go
index d9bc9592..b597fda4 100644
--- a/pkg/adapter/dubboregistry/common/common.go
+++ b/pkg/adapter/dubboregistry/common/common.go
@@ -18,8 +18,8 @@
package common
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
type RegistryEventListener interface {
diff --git a/pkg/adapter/dubboregistry/registry/base/baseregistry_test.go b/pkg/adapter/dubboregistry/registry/base/baseregistry_test.go
index 028022b5..bdd4c3e2 100644
--- a/pkg/adapter/dubboregistry/registry/base/baseregistry_test.go
+++ b/pkg/adapter/dubboregistry/registry/base/baseregistry_test.go
@@ -23,7 +23,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
import (
diff --git a/pkg/adapter/dubboregistry/registry/nacos/interface_listener.go b/pkg/adapter/dubboregistry/registry/nacos/interface_listener.go
index 563af980..a1a2de67 100644
--- a/pkg/adapter/dubboregistry/registry/nacos/interface_listener.go
+++ b/pkg/adapter/dubboregistry/registry/nacos/interface_listener.go
@@ -30,6 +30,7 @@ import (
"dubbo.apache.org/dubbo-go/v3/common/constant"
dubboConfig "dubbo.apache.org/dubbo-go/v3/config"
dubboRegistry "dubbo.apache.org/dubbo-go/v3/registry"
+
"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
diff --git a/pkg/adapter/dubboregistry/registry/nacos/service_listener.go b/pkg/adapter/dubboregistry/registry/nacos/service_listener.go
index 10175401..aa272da6 100644
--- a/pkg/adapter/dubboregistry/registry/nacos/service_listener.go
+++ b/pkg/adapter/dubboregistry/registry/nacos/service_listener.go
@@ -29,7 +29,9 @@ import (
dubboRegistry "dubbo.apache.org/dubbo-go/v3/registry"
_ "dubbo.apache.org/dubbo-go/v3/registry/nacos"
"dubbo.apache.org/dubbo-go/v3/remoting"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+
"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
nacosModel "github.com/nacos-group/nacos-sdk-go/model"
)
diff --git a/pkg/adapter/dubboregistry/registry/registry.go b/pkg/adapter/dubboregistry/registry/registry.go
index 327f16bf..cfcf17dc 100644
--- a/pkg/adapter/dubboregistry/registry/registry.go
+++ b/pkg/adapter/dubboregistry/registry/registry.go
@@ -25,8 +25,8 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/common"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/pkg/errors"
)
diff --git a/pkg/adapter/dubboregistry/registry/util.go b/pkg/adapter/dubboregistry/registry/util.go
index 653eb087..fb8140db 100644
--- a/pkg/adapter/dubboregistry/registry/util.go
+++ b/pkg/adapter/dubboregistry/registry/util.go
@@ -19,7 +19,8 @@ package registry
import (
"dubbo.apache.org/dubbo-go/v3/common"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
)
import (
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go b/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
index 4f3ceba3..da4bf475 100644
--- a/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
+++ b/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
@@ -31,7 +31,8 @@ import (
"dubbo.apache.org/dubbo-go/v3/metadata/definition"
dr "dubbo.apache.org/dubbo-go/v3/registry"
"dubbo.apache.org/dubbo-go/v3/remoting/zookeeper/curator_discovery"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/dubbogo/go-zookeeper/zk"
)
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener.go b/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener.go
index 78f16dfb..bbf3f4ac 100644
--- a/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener.go
+++ b/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener.go
@@ -25,6 +25,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/common"
+
"github.com/dubbogo/go-zookeeper/zk"
)
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/registry_test.go b/pkg/adapter/dubboregistry/registry/zookeeper/registry_test.go
index c2864453..d5d61bf1 100644
--- a/pkg/adapter/dubboregistry/registry/zookeeper/registry_test.go
+++ b/pkg/adapter/dubboregistry/registry/zookeeper/registry_test.go
@@ -22,8 +22,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/service_listener.go b/pkg/adapter/dubboregistry/registry/zookeeper/service_listener.go
index 23fe25e8..b3c5a16e 100644
--- a/pkg/adapter/dubboregistry/registry/zookeeper/service_listener.go
+++ b/pkg/adapter/dubboregistry/registry/zookeeper/service_listener.go
@@ -26,7 +26,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/common"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/dubbogo/go-zookeeper/zk"
)
diff --git a/pkg/adapter/dubboregistry/registrycenter.go b/pkg/adapter/dubboregistry/registrycenter.go
index e7387ebf..3d24f9ae 100644
--- a/pkg/adapter/dubboregistry/registrycenter.go
+++ b/pkg/adapter/dubboregistry/registrycenter.go
@@ -22,8 +22,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
import (
diff --git a/pkg/adapter/springcloud/servicediscovery/zookeeper/application_listener.go b/pkg/adapter/springcloud/servicediscovery/zookeeper/application_listener.go
index faa22c9a..ae9e9a65 100644
--- a/pkg/adapter/springcloud/servicediscovery/zookeeper/application_listener.go
+++ b/pkg/adapter/springcloud/servicediscovery/zookeeper/application_listener.go
@@ -25,6 +25,7 @@ import (
import (
"github.com/dubbogo/go-zookeeper/zk"
+
gzk "github.com/dubbogo/gost/database/kv/zk"
)
diff --git a/pkg/adapter/springcloud/servicediscovery/zookeeper/service_listener.go b/pkg/adapter/springcloud/servicediscovery/zookeeper/service_listener.go
index 728726f8..8debc8a6 100644
--- a/pkg/adapter/springcloud/servicediscovery/zookeeper/service_listener.go
+++ b/pkg/adapter/springcloud/servicediscovery/zookeeper/service_listener.go
@@ -25,6 +25,7 @@ import (
import (
"github.com/dubbogo/go-zookeeper/zk"
+
gzk "github.com/dubbogo/gost/database/kv/zk"
)
diff --git a/pkg/client/dubbo/default.go b/pkg/client/dubbo/default.go
index 7ceb9e75..412dbf43 100644
--- a/pkg/client/dubbo/default.go
+++ b/pkg/client/dubbo/default.go
@@ -18,7 +18,7 @@
package dubbo
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
)
// defaultMappingParams default http to dubbo config
diff --git a/pkg/client/dubbo/dubbo.go b/pkg/client/dubbo/dubbo.go
index 87f70859..7640ac0e 100644
--- a/pkg/client/dubbo/dubbo.go
+++ b/pkg/client/dubbo/dubbo.go
@@ -41,7 +41,7 @@ import (
hessian "github.com/apache/dubbo-go-hessian2"
- fc "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ fc "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/pkg/errors"
diff --git a/pkg/client/dubbo/dubbo_test.go b/pkg/client/dubbo/dubbo_test.go
index 7f2b4142..354fae66 100644
--- a/pkg/client/dubbo/dubbo_test.go
+++ b/pkg/client/dubbo/dubbo_test.go
@@ -26,7 +26,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/client/dubbo/mapper.go b/pkg/client/dubbo/mapper.go
index d3a998e3..ac4e66e8 100644
--- a/pkg/client/dubbo/mapper.go
+++ b/pkg/client/dubbo/mapper.go
@@ -29,7 +29,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/pkg/errors"
diff --git a/pkg/client/dubbo/mapper_test.go b/pkg/client/dubbo/mapper_test.go
index b4c2049a..59c27d34 100644
--- a/pkg/client/dubbo/mapper_test.go
+++ b/pkg/client/dubbo/mapper_test.go
@@ -25,7 +25,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/client/http/http_test.go b/pkg/client/http/http_test.go
index 721e6bdd..4e176627 100644
--- a/pkg/client/http/http_test.go
+++ b/pkg/client/http/http_test.go
@@ -26,7 +26,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/client/http/mapper.go b/pkg/client/http/mapper.go
index ce02bd85..8c324964 100644
--- a/pkg/client/http/mapper.go
+++ b/pkg/client/http/mapper.go
@@ -29,7 +29,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/pkg/errors"
)
diff --git a/pkg/client/http/mapper_test.go b/pkg/client/http/mapper_test.go
index 8f5fdde6..8a7c5354 100644
--- a/pkg/client/http/mapper_test.go
+++ b/pkg/client/http/mapper_test.go
@@ -26,7 +26,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/client/mapper.go b/pkg/client/mapper.go
index e6e9a9a0..0aa0279c 100644
--- a/pkg/client/mapper.go
+++ b/pkg/client/mapper.go
@@ -24,7 +24,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/pkg/errors"
)
diff --git a/pkg/client/request.go b/pkg/client/request.go
index c8af1e65..39f01429 100644
--- a/pkg/client/request.go
+++ b/pkg/client/request.go
@@ -23,8 +23,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
// Request request for endpoint
diff --git a/pkg/common/extension/filter/filter.go b/pkg/common/extension/filter/filter.go
index 9d7985dd..de19ab23 100644
--- a/pkg/common/extension/filter/filter.go
+++ b/pkg/common/extension/filter/filter.go
@@ -30,7 +30,6 @@ import (
import (
"github.com/apache/dubbo-go-pixiu/pkg/context/dubbo"
"github.com/apache/dubbo-go-pixiu/pkg/context/http"
- "github.com/apache/dubbo-go-pixiu/pkg/model"
)
type (
@@ -81,7 +80,7 @@ type (
// Kind returns the unique kind name to represent itself.
Kind() string
// CreateFilterFactory return the filter callback
- CreateFilter(config interface{}, bs *model.Bootstrap) (NetworkFilter, error)
+ CreateFilter(config interface{}) (NetworkFilter, error)
// Config Expose the config so that Filter Manger can inject it, so it must be a pointer
Config() interface{}
}
diff --git a/pkg/common/grpc/manager.go b/pkg/common/grpc/manager.go
index 8d223ef2..bcd3a2ed 100644
--- a/pkg/common/grpc/manager.go
+++ b/pkg/common/grpc/manager.go
@@ -30,7 +30,9 @@ import (
import (
"github.com/dubbogo/grpc-go/codes"
"github.com/dubbogo/grpc-go/status"
+
"golang.org/x/net/http2"
+
"google.golang.org/protobuf/proto"
)
@@ -50,7 +52,7 @@ type GrpcConnectionManager struct {
}
// CreateGrpcConnectionManager create grpc connection manager
-func CreateGrpcConnectionManager(hcmc *model.GRPCConnectionManagerConfig, bs *model.Bootstrap) *GrpcConnectionManager {
+func CreateGrpcConnectionManager(hcmc *model.GRPCConnectionManagerConfig) *GrpcConnectionManager {
hcm := &GrpcConnectionManager{config: hcmc}
hcm.routerCoordinator = router2.CreateRouterCoordinator(&hcmc.RouteConfig)
return hcm
diff --git a/pkg/common/http/manager.go b/pkg/common/http/manager.go
index 98d54b4b..dc09679a 100644
--- a/pkg/common/http/manager.go
+++ b/pkg/common/http/manager.go
@@ -50,7 +50,7 @@ type HttpConnectionManager struct {
}
// CreateHttpConnectionManager create http connection manager
-func CreateHttpConnectionManager(hcmc *model.HttpConnectionManagerConfig, bs *model.Bootstrap) *HttpConnectionManager {
+func CreateHttpConnectionManager(hcmc *model.HttpConnectionManagerConfig) *HttpConnectionManager {
hcm := &HttpConnectionManager{config: hcmc}
hcm.pool.New = func() interface{} {
return hcm.allocateContext()
@@ -115,7 +115,7 @@ func (hcm *HttpConnectionManager) writeResponse(c *pch.HttpContext) {
writer := c.Writer
writer.WriteHeader(c.GetStatusCode())
if _, err := writer.Write(c.TargetResp.Data); err != nil {
- panic(err)
+ logger.Errorf("write response error: %s", err)
}
}
}
diff --git a/pkg/common/http/manager_test.go b/pkg/common/http/manager_test.go
index 298dadf3..684dd2dd 100644
--- a/pkg/common/http/manager_test.go
+++ b/pkg/common/http/manager_test.go
@@ -126,7 +126,7 @@ func TestCreateHttpConnectionManager(t *testing.T) {
IdleTimeoutStr: "100",
}
- hcm := CreateHttpConnectionManager(&hcmc, nil)
+ hcm := CreateHttpConnectionManager(&hcmc)
assert.Equal(t, len(hcm.filterManager.GetFactory()), 1)
request, err := http.NewRequest("POST", "http://www.dubbogopixiu.com/api/v1?name=tc", bytes.NewReader([]byte("{\"id\":\"12345\"}")))
assert.NoError(t, err)
diff --git a/pkg/common/mock/router.go b/pkg/common/mock/router.go
index b3c61791..6302ecb4 100644
--- a/pkg/common/mock/router.go
+++ b/pkg/common/mock/router.go
@@ -18,8 +18,8 @@
package mock
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
// GetMockAPI a mock util to create router.API
diff --git a/pkg/config/api_config.go b/pkg/config/api_config.go
index 040648b7..90b8fd03 100644
--- a/pkg/config/api_config.go
+++ b/pkg/config/api_config.go
@@ -26,7 +26,7 @@ import (
)
import (
- fc "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ fc "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
etcdv3 "github.com/dubbogo/gost/database/kv/etcd/v3"
diff --git a/pkg/config/xds/cds.go b/pkg/config/xds/cds.go
index a8a8dff5..24a31210 100644
--- a/pkg/config/xds/cds.go
+++ b/pkg/config/xds/cds.go
@@ -18,8 +18,8 @@
package xds
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api"
- xdspb "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds/model"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api"
+ xdspb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
"github.com/pkg/errors"
)
@@ -103,15 +103,17 @@ func (c *CdsManager) setupCluster(clusters []*xdspb.Cluster) error {
}
for _, cluster := range clusters {
delete(toRemoveHash, cluster.Name)
+
+ makeCluster := c.makeCluster(cluster)
switch {
case c.clusterMg.HasCluster(cluster.Name):
laterApplies = append(laterApplies, func() error {
- c.clusterMg.UpdateCluster(c.makeCluster(cluster))
+ c.clusterMg.UpdateCluster(makeCluster)
return nil
})
default:
laterApplies = append(laterApplies, func() error {
- c.clusterMg.AddCluster(c.makeCluster(cluster))
+ c.clusterMg.AddCluster(makeCluster)
return nil
})
}
@@ -157,14 +159,16 @@ func (c *CdsManager) makeClusterType(cluster *xdspb.Cluster) model.DiscoveryType
return model.DiscoveryTypeValue[cluster.TypeStr]
}
-func (c *CdsManager) makeEndpoints(endpoint *xdspb.Endpoint) []*model.Endpoint {
- r := make([]*model.Endpoint, 0, 1)
- r = append(r, &model.Endpoint{
- ID: endpoint.Id,
- Name: endpoint.Name,
- Address: c.makeAddress(endpoint),
- Metadata: endpoint.Metadata,
- })
+func (c *CdsManager) makeEndpoints(endpoints []*xdspb.Endpoint) []*model.Endpoint {
+ r := make([]*model.Endpoint, len(endpoints))
+ for i, endpoint := range endpoints {
+ r[i] = &model.Endpoint{
+ ID: endpoint.Id,
+ Name: endpoint.Name,
+ Address: c.makeAddress(endpoint),
+ Metadata: endpoint.Metadata,
+ }
+ }
return r
}
diff --git a/pkg/config/xds/cds_test.go b/pkg/config/xds/cds_test.go
index c37e9d8f..71761a4d 100644
--- a/pkg/config/xds/cds_test.go
+++ b/pkg/config/xds/cds_test.go
@@ -25,8 +25,8 @@ import (
import (
"github.com/cch123/supermonkey"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds"
- pixiupb "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds/model"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
+ pixiupb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
@@ -50,13 +50,13 @@ func makeClusters() *pixiupb.PixiuExtensionClusters {
{
Name: "http-baidu",
TypeStr: "http",
- Endpoints: &pixiupb.Endpoint{
+ Endpoints: []*pixiupb.Endpoint{{
Id: "backend",
Address: &pixiupb.SocketAddress{
Address: "httpbin.org",
Port: 80,
},
- },
+ }},
},
},
}
@@ -69,13 +69,13 @@ func getCdsConfig() *core.TypedExtensionConfig {
{
Name: "http-baidu",
TypeStr: "http",
- Endpoints: &pixiupb.Endpoint{
+ Endpoints: []*pixiupb.Endpoint{{
Id: "backend",
Address: &pixiupb.SocketAddress{
Address: "httpbin.org",
Port: 80,
},
- },
+ }},
},
},
}
@@ -198,7 +198,7 @@ func TestCdsManager_makeCluster(t *testing.T) {
assert := require.New(t)
assert.Equal(cluster.Name, modelCluster.Name)
assert.Equal(cluster.TypeStr, modelCluster.TypeStr)
- assert.Equal(cluster.Endpoints.Name, modelCluster.Endpoints[0].Name)
- assert.Equal(cluster.Endpoints.Address.Address, modelCluster.Endpoints[0].Address.Address)
- assert.Equal(cluster.Endpoints.Address.Port, int64(modelCluster.Endpoints[0].Address.Port))
+ assert.Equal(cluster.Endpoints[0].Name, modelCluster.Endpoints[0].Name)
+ assert.Equal(cluster.Endpoints[0].Address.Address, modelCluster.Endpoints[0].Address.Address)
+ assert.Equal(cluster.Endpoints[0].Address.Port, int64(modelCluster.Endpoints[0].Address.Port))
}
diff --git a/pkg/config/xds/lds.go b/pkg/config/xds/lds.go
index 9a6d53e5..a0af0ae2 100644
--- a/pkg/config/xds/lds.go
+++ b/pkg/config/xds/lds.go
@@ -19,10 +19,11 @@ package xds
import (
"encoding/json"
+ "strconv"
)
import (
- xdsModel "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds/model"
+ xdsModel "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
"gopkg.in/yaml.v2"
)
@@ -102,42 +103,68 @@ func (l *LdsManager) removeListeners(toRemoveHash map[string]struct{}) {
names := make([]string, 0, len(toRemoveHash))
for name := range toRemoveHash {
names = append(names, name)
- l.listenerMg.RemoveListener(names)
}
+ l.listenerMg.RemoveListener(names)
}
// setupListeners setup listeners accord to dynamic resource
func (l *LdsManager) setupListeners(listeners []*xdsModel.Listener) {
+ //Make sure each one has a unique name like "host-port-protocol"
+ for _, v := range listeners {
+ v.Name = resolveListenerName(v.Address.SocketAddress.Address, int(v.Address.SocketAddress.Port), v.Protocol.String())
+ }
+
laterApplies := make([]func() error, 0, len(listeners))
toRemoveHash := make(map[string]struct{}, len(listeners))
- for _, listener := range listeners {
- toRemoveHash[listener.Name] = struct{}{}
+ lm := l.listenerMg
+ activeListeners, err := lm.CloneXdsControlListener()
+ if err != nil {
+ logger.Errorf("Clone Xds Control Listener fail: %s", err)
+ return
+ }
+ //put all current listeners to $toRemoveHash
+ for _, v := range activeListeners {
+ //Make sure each one has a unique name like "host-port-protocol"
+ v.Name = resolveListenerName(v.Address.SocketAddress.Address, v.Address.SocketAddress.Port, v.ProtocolStr)
+ toRemoveHash[v.Name] = struct{}{}
}
for _, listener := range listeners {
delete(toRemoveHash, listener.Name)
+
modelListener := l.makeListener(listener)
// add or update later after removes
- laterApplies = append(laterApplies, func() error {
- err := l.listenerMg.AddOrUpdateListener(&modelListener)
- if err != nil {
- logger.Errorf("can not add/update listener config=> %v", modelListener)
- }
- return nil
- })
+ switch {
+ case lm.HasListener(modelListener.Name):
+ laterApplies = append(laterApplies, func() error {
+ return lm.UpdateListener(&modelListener)
+ })
+ default:
+ laterApplies = append(laterApplies, func() error {
+ return lm.AddListener(&modelListener)
+ })
+ }
}
+ // remove the listeners first to prevent tcp port conflict
l.removeListeners(toRemoveHash)
- for _, fn := range laterApplies { //do update and add new cluster.
+ //do update and add new cluster.
+ for _, fn := range laterApplies {
if err := fn(); err != nil {
logger.Errorf("can not modify listener", err)
}
}
}
+func resolveListenerName(host string, port int, protocol string) string {
+ return host + "-" + strconv.Itoa(port) + "-" + protocol
+}
+
func (l *LdsManager) makeListener(listener *xdsModel.Listener) model.Listener {
return model.Listener{
Name: listener.Name,
+ ProtocolStr: listener.Protocol.String(),
+ Protocol: model.ProtocolType(model.ProtocolTypeValue[listener.Protocol.String()]),
Address: l.makeAddress(listener.Address),
FilterChain: l.makeFilterChain(listener.FilterChain),
Config: nil, // todo set the additional config
diff --git a/pkg/config/xds/lds_test.go b/pkg/config/xds/lds_test.go
index 8514a641..62dbb967 100644
--- a/pkg/config/xds/lds_test.go
+++ b/pkg/config/xds/lds_test.go
@@ -22,13 +22,20 @@ import (
)
import (
- pixiupb "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds/model"
+ pixiupb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
+ "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "google.golang.org/protobuf/encoding/protojson"
+
structpb2 "google.golang.org/protobuf/types/known/structpb"
)
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/model"
+)
+
func TestLdsManager_makeConfig(t *testing.T) {
var httpManagerConfigYaml = `
route_config:
@@ -138,3 +145,138 @@ http_filters:
})
}
}
+
+func TestMakeListener(t *testing.T) {
+ lm := &LdsManager{}
+ json := `
+{
+ "name": "net/http",
+ "address": {
+ "socketAddress": {
+ "address": "0.0.0.0",
+ "port": "8080"
+ }
+ },
+ "filterChain": {
+ "filters": [
+ {
+ "name": "dgp.filter.httpconnectionmanager",
+ "struct": {
+ "http_filters": [
+ {
+ "config": null,
+ "name": "dgp.filter.http.httpproxy"
+ }
+ ],
+ "route_config": {
+ "routes": [
+ {
+ "match": {
+ "prefix": "/"
+ },
+ "route": {
+ "cluster": "http_bin",
+ "cluster_not_found_response_code": 503
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+`
+ l := &pixiupb.Listener{}
+ if err := protojson.Unmarshal([]byte(json), l); err != nil {
+ t.Fatal(err)
+ }
+ listener := lm.makeListener(l)
+ assert.NotNil(t, listener)
+ assert.Equal(t, "net/http", listener.Name)
+ assert.Equal(t, "0.0.0.0", listener.Address.SocketAddress.Address)
+ assert.Equal(t, 8080, listener.Address.SocketAddress.Port)
+ assert.Equal(t, 1, len(listener.FilterChain.Filters))
+}
+
+type mockListenerManager struct {
+ m map[string]*model.Listener
+}
+
+func (m *mockListenerManager) AddListener(l *model.Listener) error {
+ m.m[l.Name] = l
+ return nil
+}
+
+func (m *mockListenerManager) UpdateListener(l *model.Listener) error {
+ m.m[l.Name] = l
+ return nil
+}
+
+func (m *mockListenerManager) RemoveListener(names []string) {
+ for _, name := range names {
+ delete(m.m, name)
+ }
+}
+
+func (m *mockListenerManager) HasListener(name string) bool {
+ _, ok := m.m[name]
+ return ok
+}
+
+func (m *mockListenerManager) CloneXdsControlListener() ([]*model.Listener, error) {
+ var res []*model.Listener
+ for _, v := range m.m {
+ res = append(res, v)
+ }
+ return res, nil
+}
+
+func TestSetupListeners(t *testing.T) {
+ mock := &mockListenerManager{m: map[string]*model.Listener{}}
+ lm := &LdsManager{listenerMg: mock}
+
+ listeners := []*pixiupb.Listener{
+ {
+ Protocol: pixiupb.Listener_HTTP,
+ Address: &pixiupb.Address{
+ SocketAddress: &pixiupb.SocketAddress{
+ Address: "0.0.0.0",
+ Port: 8080,
+ },
+ },
+ FilterChain: &pixiupb.FilterChain{},
+ },
+ {
+ Protocol: pixiupb.Listener_TRIPLE,
+ Address: &pixiupb.Address{
+ SocketAddress: &pixiupb.SocketAddress{
+ Address: "0.0.0.0",
+ Port: 8081,
+ },
+ },
+ FilterChain: &pixiupb.FilterChain{},
+ },
+ }
+ lm.setupListeners(listeners)
+ for _, v := range listeners {
+ assert.Equal(t, v.Protocol.String(), model.ProtocolTypeName[int32(mock.m[v.Name].Protocol)])
+ assert.Equal(t, v.Address.SocketAddress.Address, mock.m[v.Name].Address.SocketAddress.Address)
+ assert.Equal(t, int(v.Address.SocketAddress.Port), mock.m[v.Name].Address.SocketAddress.Port)
+ }
+
+ newListeners := []*pixiupb.Listener{
+ {
+ Protocol: pixiupb.Listener_HTTP,
+ Address: &pixiupb.Address{
+ SocketAddress: &pixiupb.SocketAddress{
+ Address: "0.0.0.0",
+ Port: 8080,
+ },
+ },
+ FilterChain: &pixiupb.FilterChain{},
+ },
+ }
+ lm.setupListeners(newListeners)
+ assert.Equal(t, 1, len(mock.m))
+}
diff --git a/pkg/config/xds/xds.go b/pkg/config/xds/xds.go
index 62887692..9472570f 100644
--- a/pkg/config/xds/xds.go
+++ b/pkg/config/xds/xds.go
@@ -22,7 +22,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
)
import (
@@ -81,7 +81,7 @@ func (a *Xds) Start() {
DiscoverApi: a.createApiManager(a.dynamicResourceMg.GetLds(), a.dynamicResourceMg.GetNode(), xds.ListenerType),
listenerMg: a.listenerMg,
}
- if err := a.lds.Fetch(); err != nil {
+ if err := a.lds.Delta(); err != nil {
logger.Errorf("can not fetch lds err is %+v", err)
}
}
diff --git a/pkg/config/xds/xds_test.go b/pkg/config/xds/xds_test.go
index dc2045ff..8588ddb3 100644
--- a/pkg/config/xds/xds_test.go
+++ b/pkg/config/xds/xds_test.go
@@ -26,7 +26,7 @@ import (
import (
monkey "github.com/cch123/supermonkey"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
"github.com/golang/mock/gomock"
diff --git a/pkg/context/http/context.go b/pkg/context/http/context.go
index 978ce689..6e7d7198 100644
--- a/pkg/context/http/context.go
+++ b/pkg/context/http/context.go
@@ -28,7 +28,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
import (
diff --git a/pkg/filter/header/header_test.go b/pkg/filter/header/header_test.go
index 5643a97d..6d3a9b7b 100644
--- a/pkg/filter/header/header_test.go
+++ b/pkg/filter/header/header_test.go
@@ -24,8 +24,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/filter/http/apiconfig/api/discovery_service.go b/pkg/filter/http/apiconfig/api/discovery_service.go
index c9f0c5ff..866e18da 100644
--- a/pkg/filter/http/apiconfig/api/discovery_service.go
+++ b/pkg/filter/http/apiconfig/api/discovery_service.go
@@ -24,8 +24,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- fr "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ fr "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
import (
diff --git a/pkg/filter/http/apiconfig/api/discovery_service_test.go b/pkg/filter/http/apiconfig/api/discovery_service_test.go
index d12dda85..2e82b9a7 100644
--- a/pkg/filter/http/apiconfig/api/discovery_service_test.go
+++ b/pkg/filter/http/apiconfig/api/discovery_service_test.go
@@ -23,7 +23,7 @@ import (
)
import (
- fc "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ fc "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/filter/http/apiconfig/api_config.go b/pkg/filter/http/apiconfig/api_config.go
index 36c42433..52b3b8a6 100644
--- a/pkg/filter/http/apiconfig/api_config.go
+++ b/pkg/filter/http/apiconfig/api_config.go
@@ -22,8 +22,8 @@ import (
)
import (
- fc "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ fc "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/pkg/errors"
)
diff --git a/pkg/filter/http/remote/call.go b/pkg/filter/http/remote/call.go
index 7deb2659..d40fcc02 100644
--- a/pkg/filter/http/remote/call.go
+++ b/pkg/filter/http/remote/call.go
@@ -27,8 +27,8 @@ import (
)
import (
- apiConf "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ apiConf "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
import (
diff --git a/pkg/filter/network/dubboproxy/manager.go b/pkg/filter/network/dubboproxy/manager.go
index 971d1efe..534ace0e 100644
--- a/pkg/filter/network/dubboproxy/manager.go
+++ b/pkg/filter/network/dubboproxy/manager.go
@@ -56,7 +56,7 @@ type DubboProxyConnectionManager struct {
}
// CreateDubboProxyConnectionManager create dubbo proxy connection manager
-func CreateDubboProxyConnectionManager(config *model.DubboProxyConnectionManagerConfig, bs *model.Bootstrap) *DubboProxyConnectionManager {
+func CreateDubboProxyConnectionManager(config *model.DubboProxyConnectionManagerConfig) *DubboProxyConnectionManager {
filterManager := NewDubboFilterManager(config.DubboFilters)
hcm := &DubboProxyConnectionManager{config: config, codec: &dubbo.DubboCodec{}, filterManager: filterManager}
hcm.routerCoordinator = router2.CreateRouterCoordinator(&config.RouteConfig)
diff --git a/pkg/filter/network/dubboproxy/plugin.go b/pkg/filter/network/dubboproxy/plugin.go
index bfa34cd8..cb033b2b 100644
--- a/pkg/filter/network/dubboproxy/plugin.go
+++ b/pkg/filter/network/dubboproxy/plugin.go
@@ -42,12 +42,12 @@ func (p *Plugin) Kind() string {
}
// CreateFilter create dubbo networkfilter
-func (p *Plugin) CreateFilter(config interface{}, bs *model.Bootstrap) (filter.NetworkFilter, error) {
+func (p *Plugin) CreateFilter(config interface{}) (filter.NetworkFilter, error) {
hcmc, ok := config.(*model.DubboProxyConnectionManagerConfig)
if !ok {
panic("CreateFilter occur some exception for the type is not suitable one.")
}
- return CreateDubboProxyConnectionManager(hcmc, bs), nil
+ return CreateDubboProxyConnectionManager(hcmc), nil
}
// Config return DubboProxyConnectionManagerConfig
diff --git a/pkg/filter/network/grpcconnectionmanager/plugin.go b/pkg/filter/network/grpcconnectionmanager/plugin.go
index b20eabe4..c6002cf8 100644
--- a/pkg/filter/network/grpcconnectionmanager/plugin.go
+++ b/pkg/filter/network/grpcconnectionmanager/plugin.go
@@ -42,9 +42,9 @@ func (p *Plugin) Kind() string {
}
// CreateFilter create grpc network filter
-func (p *Plugin) CreateFilter(config interface{}, bs *model.Bootstrap) (filter.NetworkFilter, error) {
+func (p *Plugin) CreateFilter(config interface{}) (filter.NetworkFilter, error) {
hcmc := config.(*model.GRPCConnectionManagerConfig)
- return grpc.CreateGrpcConnectionManager(hcmc, bs), nil
+ return grpc.CreateGrpcConnectionManager(hcmc), nil
}
// Config return GRPCConnectionManagerConfig
diff --git a/pkg/filter/network/httpconnectionmanager/plugin.go b/pkg/filter/network/httpconnectionmanager/plugin.go
index dd1bee21..ce90f374 100644
--- a/pkg/filter/network/httpconnectionmanager/plugin.go
+++ b/pkg/filter/network/httpconnectionmanager/plugin.go
@@ -42,9 +42,9 @@ func (p *Plugin) Kind() string {
}
// CreateFilter create http network filter
-func (p *Plugin) CreateFilter(config interface{}, bs *model.Bootstrap) (filter.NetworkFilter, error) {
+func (p *Plugin) CreateFilter(config interface{}) (filter.NetworkFilter, error) {
hcmc := config.(*model.HttpConnectionManagerConfig)
- return http.CreateHttpConnectionManager(hcmc, bs), nil
+ return http.CreateHttpConnectionManager(hcmc), nil
}
// Config return HttpConnectionManagerConfig
diff --git a/pkg/filter/seata/filter.go b/pkg/filter/seata/filter.go
index c274d6ba..2103e99a 100644
--- a/pkg/filter/seata/filter.go
+++ b/pkg/filter/seata/filter.go
@@ -25,6 +25,7 @@ import (
import (
"github.com/opentrx/seata-golang/v2/pkg/apis"
"github.com/opentrx/seata-golang/v2/pkg/util/runtime"
+
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
diff --git a/pkg/filter/sentinel/circuitbreaker/circuit_breaker_test.go b/pkg/filter/sentinel/circuitbreaker/circuit_breaker_test.go
index f0ef7600..92c00bc1 100644
--- a/pkg/filter/sentinel/circuitbreaker/circuit_breaker_test.go
+++ b/pkg/filter/sentinel/circuitbreaker/circuit_breaker_test.go
@@ -24,6 +24,7 @@ import (
import (
"github.com/alibaba/sentinel-golang/core/circuitbreaker"
+
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/filter/sentinel/ratelimit/config.go b/pkg/filter/sentinel/ratelimit/config.go
index 5dd913aa..fb19590e 100644
--- a/pkg/filter/sentinel/ratelimit/config.go
+++ b/pkg/filter/sentinel/ratelimit/config.go
@@ -18,11 +18,11 @@
package ratelimit
import (
- pkgs "github.com/apache/dubbo-go-pixiu/pkg/filter/sentinel"
+ "github.com/alibaba/sentinel-golang/core/flow"
)
import (
- "github.com/alibaba/sentinel-golang/core/flow"
+ pkgs "github.com/apache/dubbo-go-pixiu/pkg/filter/sentinel"
)
type (
diff --git a/pkg/filterchain/network_filter_chain.go b/pkg/filterchain/network_filter_chain.go
index 1bcd3ebc..cc6787ff 100644
--- a/pkg/filterchain/network_filter_chain.go
+++ b/pkg/filterchain/network_filter_chain.go
@@ -83,7 +83,7 @@ func (fc *NetworkFilterChain) OnTripleData(ctx context.Context, methodName strin
}
// CreateNetworkFilterChain create network filter chain
-func CreateNetworkFilterChain(config model.FilterChain, bs *model.Bootstrap) *NetworkFilterChain {
+func CreateNetworkFilterChain(config model.FilterChain) *NetworkFilterChain {
var filters []filter.NetworkFilter
for _, f := range config.Filters {
@@ -99,7 +99,7 @@ func CreateNetworkFilterChain(config model.FilterChain, bs *model.Bootstrap) *Ne
continue
}
- filter, err := p.CreateFilter(config, bs)
+ filter, err := p.CreateFilter(config)
if err != nil {
logger.Error("CreateNetworkFilterChain %s createFilter error %s", f.Name, err)
continue
diff --git a/pkg/listener/http/http_listener.go b/pkg/listener/http/http_listener.go
index 6c0e4bf3..6f7d4cdd 100644
--- a/pkg/listener/http/http_listener.go
+++ b/pkg/listener/http/http_listener.go
@@ -57,7 +57,7 @@ type (
)
func newHttpListenerService(lc *model.Listener, bs *model.Bootstrap) (listener.ListenerService, error) {
- fc := filterchain.CreateNetworkFilterChain(lc.FilterChain, bs)
+ fc := filterchain.CreateNetworkFilterChain(lc.FilterChain)
return &HttpListenerService{
BaseListenerService: listener.BaseListenerService{
Config: lc,
@@ -80,6 +80,22 @@ func (ls *HttpListenerService) Start() error {
return nil
}
+func (ls *HttpListenerService) Close() error {
+ return ls.srv.Close()
+}
+
+func (ls *HttpListenerService) ShutDown() error {
+ //TODO implement me
+ panic("implement me")
+}
+
+func (ls *HttpListenerService) Refresh(c model.Listener) error {
+ // There is no need to lock here for now, as there is at most one NetworkFilter
+ fc := filterchain.CreateNetworkFilterChain(c.FilterChain)
+ ls.FilterChain = fc
+ return nil
+}
+
func (ls *HttpListenerService) httpsListener() {
hl := createDefaultHttpWorker(ls)
diff --git a/pkg/listener/http2/http2_listener.go b/pkg/listener/http2/http2_listener.go
index 5da0dbb7..13e457a0 100644
--- a/pkg/listener/http2/http2_listener.go
+++ b/pkg/listener/http2/http2_listener.go
@@ -68,7 +68,7 @@ func (h *handleWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func newHttp2ListenerService(lc *model.Listener, bs *model.Bootstrap) (listener.ListenerService, error) {
- fc := filterchain.CreateNetworkFilterChain(lc.FilterChain, bs)
+ fc := filterchain.CreateNetworkFilterChain(lc.FilterChain)
return &Http2ListenerService{
BaseListenerService: listener.BaseListenerService{
Config: lc,
@@ -80,7 +80,7 @@ func newHttp2ListenerService(lc *model.Listener, bs *model.Bootstrap) (listener.
}
// Start start listen
-func (ls Http2ListenerService) Start() error {
+func (ls *Http2ListenerService) Start() error {
sa := ls.Config.Address.SocketAddress
addr := resolveAddress(sa.Address + ":" + strconv.Itoa(sa.Port))
@@ -105,12 +105,32 @@ func (ls Http2ListenerService) Start() error {
go func() {
if err := ls.server.Serve(ls.listener); err != nil {
- logger.Error("Http2ListenerService Start error %s", err)
+ if err == http.ErrServerClosed {
+ logger.Infof("Listener %s closed", ls.Config.Name)
+ return
+ }
+ logger.Errorf("Http2ListenerService.Serve: %v", err)
}
}()
return nil
}
+func (ls *Http2ListenerService) Close() error {
+ return ls.server.Close()
+}
+
+func (ls *Http2ListenerService) ShutDown() error {
+ //TODO implement me
+ panic("implement me")
+}
+
+func (ls *Http2ListenerService) Refresh(c model.Listener) error {
+ // There is no need to lock here for now, as there is at most one NetworkFilter
+ fc := filterchain.CreateNetworkFilterChain(c.FilterChain)
+ ls.FilterChain = fc
+ return nil
+}
+
func resolveAddress(addr string) string {
if addr == "" {
logger.Debug("Addr is undefined. Using port :8080 by default")
diff --git a/pkg/listener/listener.go b/pkg/listener/listener.go
index 5b9a76db..52403fcd 100644
--- a/pkg/listener/listener.go
+++ b/pkg/listener/listener.go
@@ -30,7 +30,14 @@ var factoryMap = make(map[model.ProtocolType]func(lc *model.Listener, bs *model.
type (
ListenerService interface {
+ // Start the listener service
Start() error
+ // Close the listener service forcefully
+ Close() error
+ // ShutDown gracefully shuts down the listener.
+ ShutDown() error
+ // Refresh config
+ Refresh(model.Listener) error
}
BaseListenerService struct {
diff --git a/pkg/listener/tcp/tcp_listener.go b/pkg/listener/tcp/tcp_listener.go
index 004a4905..71c2f0fa 100644
--- a/pkg/listener/tcp/tcp_listener.go
+++ b/pkg/listener/tcp/tcp_listener.go
@@ -51,7 +51,7 @@ func newTcpListenerService(lc *model.Listener, bs *model.Bootstrap) (listener.Li
// todo taskPoolMode
server := getty.NewTCPServer(serverOpts...)
- fc := filterchain.CreateNetworkFilterChain(lc.FilterChain, bs)
+ fc := filterchain.CreateNetworkFilterChain(lc.FilterChain)
return &TcpListenerService{
BaseListenerService: listener.BaseListenerService{
Config: lc,
@@ -67,6 +67,23 @@ func (ls *TcpListenerService) Start() error {
return nil
}
+func (ls *TcpListenerService) Close() error {
+ ls.server.Close()
+ return nil
+}
+
+func (ls *TcpListenerService) ShutDown() error {
+ //TODO implement me
+ panic("implement me")
+}
+
+func (ls *TcpListenerService) Refresh(c model.Listener) error {
+ // There is no need to lock here for now, as there is at most one NetworkFilter
+ fc := filterchain.CreateNetworkFilterChain(c.FilterChain)
+ ls.FilterChain = fc
+ return nil
+}
+
func (ls *TcpListenerService) newSession(session getty.Session) (err error) {
tcpConn, ok := session.Conn().(*net.TCPConn)
diff --git a/pkg/listener/triple/triple_listener.go b/pkg/listener/triple/triple_listener.go
index a33e4c61..44312099 100644
--- a/pkg/listener/triple/triple_listener.go
+++ b/pkg/listener/triple/triple_listener.go
@@ -56,7 +56,7 @@ type (
func newTripleListenerService(lc *model.Listener, bs *model.Bootstrap) (listener.ListenerService, error) {
- fc := filterchain.CreateNetworkFilterChain(lc.FilterChain, bs)
+ fc := filterchain.CreateNetworkFilterChain(lc.FilterChain)
ls := &TripleListenerService{
BaseListenerService: listener.BaseListenerService{
Config: lc,
@@ -88,6 +88,23 @@ func (ls *TripleListenerService) Start() error {
return nil
}
+func (ls *TripleListenerService) Close() error {
+ ls.server.Stop()
+ return nil
+}
+
+func (ls *TripleListenerService) ShutDown() error {
+ //TODO implement me
+ panic("implement me")
+}
+
+func (ls *TripleListenerService) Refresh(c model.Listener) error {
+ // There is no need to lock here for now, as there is at most one NetworkFilter
+ fc := filterchain.CreateNetworkFilterChain(c.FilterChain)
+ ls.FilterChain = fc
+ return nil
+}
+
// GetReqParamsInterfaces get params
func (d *ProxyService) GetReqParamsInterfaces(methodName string) ([]interface{}, bool) {
val, ok := d.reqTypeMap.Load(methodName)
diff --git a/pkg/model/base.go b/pkg/model/base.go
index d29bd98f..486fd00a 100644
--- a/pkg/model/base.go
+++ b/pkg/model/base.go
@@ -22,7 +22,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api"
)
type Metadata struct {
diff --git a/pkg/pool/pool.go b/pkg/pool/pool.go
index 0f7f61c7..92728751 100644
--- a/pkg/pool/pool.go
+++ b/pkg/pool/pool.go
@@ -23,7 +23,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
)
import (
diff --git a/pkg/remote/zookeeper/client.go b/pkg/remote/zookeeper/client.go
index 7d850d36..77794b6f 100644
--- a/pkg/remote/zookeeper/client.go
+++ b/pkg/remote/zookeeper/client.go
@@ -25,6 +25,7 @@ import (
import (
gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
+
perrors "github.com/pkg/errors"
)
diff --git a/pkg/router/api.go b/pkg/router/api.go
index f6d9d602..28ac8986 100644
--- a/pkg/router/api.go
+++ b/pkg/router/api.go
@@ -23,7 +23,7 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
)
import (
diff --git a/pkg/router/api_test.go b/pkg/router/api_test.go
index 0718e317..df9fabb1 100644
--- a/pkg/router/api_test.go
+++ b/pkg/router/api_test.go
@@ -23,8 +23,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/router/route.go b/pkg/router/route.go
index 0587f584..1bada518 100644
--- a/pkg/router/route.go
+++ b/pkg/router/route.go
@@ -24,8 +24,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/pkg/errors"
)
diff --git a/pkg/router/route_test.go b/pkg/router/route_test.go
index 9d70406c..a72faccb 100644
--- a/pkg/router/route_test.go
+++ b/pkg/router/route_test.go
@@ -22,8 +22,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/server/api_config_manager.go b/pkg/server/api_config_manager.go
index 81179d8c..1b7af1be 100644
--- a/pkg/server/api_config_manager.go
+++ b/pkg/server/api_config_manager.go
@@ -22,8 +22,8 @@ import (
)
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api/config"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/router"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api/config"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/router"
"github.com/pkg/errors"
)
diff --git a/pkg/server/controls/controls.go b/pkg/server/controls/controls.go
index 4bebfcc3..ade8adc7 100644
--- a/pkg/server/controls/controls.go
+++ b/pkg/server/controls/controls.go
@@ -31,8 +31,11 @@ type (
}
ListenerManager interface {
+ AddListener(m *model.Listener) error
+ UpdateListener(m *model.Listener) error
RemoveListener(names []string)
- AddOrUpdateListener(m *model.Listener) error
+ HasListener(name string) bool
+ CloneXdsControlListener() ([]*model.Listener, error)
}
DynamicResourceManager interface {
diff --git a/pkg/server/controls/mocks/mocks.go b/pkg/server/controls/mocks/mocks.go
index a91ab0e7..8d18d787 100644
--- a/pkg/server/controls/mocks/mocks.go
+++ b/pkg/server/controls/mocks/mocks.go
@@ -142,9 +142,9 @@ func (m *MockListenerManager) EXPECT() *MockListenerManagerMockRecorder {
}
// AddOrUpdateListener mocks base method.
-func (m_2 *MockListenerManager) AddOrUpdateListener(m *model.Listener) error {
+func (m_2 *MockListenerManager) AddListener(m *model.Listener) error {
m_2.ctrl.T.Helper()
- ret := m_2.ctrl.Call(m_2, "AddOrUpdateListener", m)
+ ret := m_2.ctrl.Call(m_2, "AddListener", m)
ret0, _ := ret[0].(error)
return ret0
}
@@ -152,7 +152,7 @@ func (m_2 *MockListenerManager) AddOrUpdateListener(m *model.Listener) error {
// AddOrUpdateListener indicates an expected call of AddOrUpdateListener.
func (mr *MockListenerManagerMockRecorder) AddOrUpdateListener(m interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddOrUpdateListener", reflect.TypeOf((*MockListenerManager)(nil).AddOrUpdateListener), m)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddListener", reflect.TypeOf((*MockListenerManager)(nil).AddListener), m)
}
// RemoveListener mocks base method.
diff --git a/pkg/server/dynamic_resource_manager.go b/pkg/server/dynamic_resource_manager.go
index 51f82c68..039fdde6 100644
--- a/pkg/server/dynamic_resource_manager.go
+++ b/pkg/server/dynamic_resource_manager.go
@@ -18,7 +18,7 @@
package server
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/api"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/api"
"github.com/pkg/errors"
)
diff --git a/pkg/server/listener_manager.go b/pkg/server/listener_manager.go
index 0b09aadc..6181b5b8 100644
--- a/pkg/server/listener_manager.go
+++ b/pkg/server/listener_manager.go
@@ -19,6 +19,14 @@ package server
import (
"runtime/debug"
+ "strconv"
+ "sync"
+)
+
+import (
+ "github.com/pkg/errors"
+
+ "gopkg.in/yaml.v2"
)
import (
@@ -30,63 +38,101 @@ import (
// wrapListenerService wrap listener service and its configuration.
type wrapListenerService struct {
listener.ListenerService
- cfg *model.Listener
+
+ config *model.Listener
}
// ListenerManager the listener manager
type ListenerManager struct {
- activeListener []*model.Listener
- bootstrap *model.Bootstrap
- activeListenerService []*wrapListenerService
+ bootstrap *model.Bootstrap
+
+ // name(host-port-protocol) -> wrapListenerService
+ activeListenerService map[string]*wrapListenerService
+ //readWriteLock
+ rwLock *sync.RWMutex
}
// CreateDefaultListenerManager create listener manager from config
func CreateDefaultListenerManager(bs *model.Bootstrap) *ListenerManager {
+ listeners := map[string]*wrapListenerService{}
sl := bs.GetStaticListeners()
- var listeners []*wrapListenerService
- for _, lsCof := range bs.StaticResources.Listeners {
+
+ for _, lsCof := range sl {
ls, err := listener.CreateListenerService(lsCof, bs)
if err != nil {
logger.Error("CreateDefaultListenerManager %s error: %v", lsCof.Name, err)
}
- listeners = append(listeners, &wrapListenerService{ls, lsCof})
+ listeners[resolveListenerName(lsCof)] = &wrapListenerService{
+ config: lsCof,
+ ListenerService: ls,
+ }
}
return &ListenerManager{
- activeListener: sl,
activeListenerService: listeners,
bootstrap: bs,
+ rwLock: &sync.RWMutex{},
}
}
-func (lm *ListenerManager) AddOrUpdateListener(lsConf *model.Listener) error {
- //todo add sync lock for concurrent using
- if theListener := lm.getListener(lsConf.Name); theListener != nil {
- lm.updateListener(theListener, lsConf)
- return nil
- }
+func resolveListenerName(c *model.Listener) string {
+ return c.Address.SocketAddress.Address + "-" + strconv.Itoa(c.Address.SocketAddress.Port) + "-" + c.ProtocolStr
+}
+
+func (lm *ListenerManager) AddListener(lsConf *model.Listener) error {
+ logger.Infof("Add Listener %s", lsConf.Name)
ls, err := listener.CreateListenerService(lsConf, lm.bootstrap)
if err != nil {
return err
}
- lm.startListenerServiceAsync(ls)
lm.addListenerService(ls, lsConf)
- lm.activeListener = append(lm.activeListener, lsConf)
+ lm.startListenerServiceAsync(ls)
+ return nil
+}
+
+func (lm *ListenerManager) UpdateListener(m *model.Listener) error {
+ // lock
+ lm.rwLock.Lock()
+ defer lm.rwLock.Unlock()
+ ls, ok := lm.activeListenerService[m.Name]
+ if !ok {
+ return errors.New("ListenerManager UpdateListener error: listener not found")
+ }
+ logger.Infof("Update Listener %s", m.Name)
+ ls.config = m
+ err := ls.Refresh(*m)
+ if err != nil {
+ logger.Warnf("Update Listener %s error: %s", m.Name, err)
+ return err
+ }
return nil
}
-func (lm *ListenerManager) updateListener(listener *model.Listener, to *model.Listener) {
- //todo update listener and service
- panic("not implement")
+func (lm *ListenerManager) HasListener(name string) bool {
+ lm.rwLock.RLock()
+ defer lm.rwLock.RUnlock()
+ _, ok := lm.activeListenerService[name]
+ return ok
}
-func (lm *ListenerManager) getListener(name string) *model.Listener {
- for _, l := range lm.activeListener {
- if l.Name == name {
- return l
- }
+func (lm *ListenerManager) CloneXdsControlListener() ([]*model.Listener, error) {
+ lm.rwLock.RLock()
+ defer lm.rwLock.RUnlock()
+
+ var listeners []*model.Listener
+ for _, ls := range lm.activeListenerService {
+ listeners = append(listeners, ls.config)
}
- return nil
+ //deep copy
+ bytes, err := yaml.Marshal(listeners)
+ if err != nil {
+ return nil, err
+ }
+ var cloneListeners []*model.Listener
+ if err = yaml.Unmarshal(bytes, &cloneListeners); err != nil {
+ return nil, err
+ }
+ return cloneListeners, nil
}
func (lm *ListenerManager) StartListen() {
@@ -108,25 +154,52 @@ func (lm *ListenerManager) startListenerServiceAsync(s listener.ListenerService)
}()
err := s.Start()
if err != nil {
- logger.Error("start listener service error. %v", err)
+ logger.Errorf("start listener service error. %v", err)
}
}()
return done
}
func (lm *ListenerManager) addListenerService(ls listener.ListenerService, lsConf *model.Listener) {
- lm.activeListenerService = append(lm.activeListenerService, &wrapListenerService{ls, lsConf})
+ lm.rwLock.Lock()
+ defer lm.rwLock.Unlock()
+ lm.activeListenerService[resolveListenerName(lsConf)] = &wrapListenerService{
+ config: lsConf,
+ ListenerService: ls,
+ }
}
func (lm *ListenerManager) GetListenerService(name string) listener.ListenerService {
- for i := range lm.activeListenerService {
- if lm.activeListenerService[i].cfg.Name == name {
- return lm.activeListenerService[i]
- }
+ lm.rwLock.RLock()
+ defer lm.rwLock.RUnlock()
+
+ ls, ok := lm.activeListenerService[name]
+ if ok {
+ return ls
}
return nil
}
func (lm *ListenerManager) RemoveListener(names []string) {
- //todo implement remove Listener and ListenerService
+ //close ListenerService
+ for _, name := range names {
+ logger.Infof("listener %s closing", name)
+ ls := lm.GetListenerService(name)
+ if ls == nil {
+ logger.Warnf("listener %s not found", name)
+ continue
+ }
+ if err := ls.Close(); err != nil {
+ logger.Errorf("close listener %s service error. %s", name, err)
+ continue
+ }
+ logger.Infof("listener %s closed", name)
+ }
+
+ lm.rwLock.Lock()
+ defer lm.rwLock.Unlock()
+ //remove from activeListenerService
+ for _, name := range names {
+ delete(lm.activeListenerService, name)
+ }
}
diff --git a/pkg/server/pixiu_start.go b/pkg/server/pixiu_start.go
index b1a80868..ade0e799 100644
--- a/pkg/server/pixiu_start.go
+++ b/pkg/server/pixiu_start.go
@@ -106,7 +106,13 @@ func (s *Server) Start() {
if addr.Port == 0 {
addr.Port = constant.PprofDefaultPort
}
- go http.ListenAndServe(addr.Address+":"+strconv.Itoa(addr.Port), nil)
+ go func() {
+ err := http.ListenAndServe(addr.Address+":"+strconv.Itoa(addr.Port), nil)
+ if err != nil {
+ logger.Warnf("Pprof server start failed, err: %v", err)
+ return
+ }
+ }()
logger.Infof("[dubbopixiu go pprof] httpListener start by : %s", addr.Address+":"+strconv.Itoa(addr.Port))
}
}
diff --git a/samples/dubbogo/multi/server/app/student.go b/samples/dubbogo/multi/server/app/student.go
index 9dc470ec..e7b52ed3 100644
--- a/samples/dubbogo/multi/server/app/student.go
+++ b/samples/dubbogo/multi/server/app/student.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/multi/server/app/teacher.go b/samples/dubbogo/multi/server/app/teacher.go
index bf52943b..9524f7a3 100644
--- a/samples/dubbogo/multi/server/app/teacher.go
+++ b/samples/dubbogo/multi/server/app/teacher.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/benchmark/server/app/user.go b/samples/dubbogo/simple/benchmark/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/benchmark/server/app/user.go
+++ b/samples/dubbogo/simple/benchmark/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/jaeger/server/app/user.go b/samples/dubbogo/simple/jaeger/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/jaeger/server/app/user.go
+++ b/samples/dubbogo/simple/jaeger/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/mix/server/app/user.go b/samples/dubbogo/simple/mix/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/mix/server/app/user.go
+++ b/samples/dubbogo/simple/mix/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/proxy/server/app/user.go b/samples/dubbogo/simple/proxy/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/proxy/server/app/user.go
+++ b/samples/dubbogo/simple/proxy/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/query/server/app/user.go b/samples/dubbogo/simple/query/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/query/server/app/user.go
+++ b/samples/dubbogo/simple/query/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/resolve/server/app/user.go b/samples/dubbogo/simple/resolve/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/resolve/server/app/user.go
+++ b/samples/dubbogo/simple/resolve/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/dubbogo/simple/triple/protobuf/api/helloworld.pb.go b/samples/dubbogo/simple/triple/protobuf/api/helloworld.pb.go
index 661ea075..da178a60 100644
--- a/samples/dubbogo/simple/triple/protobuf/api/helloworld.pb.go
+++ b/samples/dubbogo/simple/triple/protobuf/api/helloworld.pb.go
@@ -45,7 +45,7 @@ import (
)
import (
- proto "github.com/golang/protobuf/proto"
+ proto "github.com/golang/protobuf/proto" //nolint
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
diff --git a/samples/dubbogo/simple/triple/server/app/greeter.go b/samples/dubbogo/simple/triple/server/app/greeter.go
index 079c476e..5edbf406 100644
--- a/samples/dubbogo/simple/triple/server/app/greeter.go
+++ b/samples/dubbogo/simple/triple/server/app/greeter.go
@@ -25,10 +25,13 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/common/logger"
- triplepb "github.com/apache/dubbo-go-pixiu/samples/dubbogo/simple/triple/server/protobuf/api"
tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
)
+import (
+ triplepb "github.com/apache/dubbo-go-pixiu/samples/dubbogo/simple/triple/server/protobuf/api"
+)
+
type GreeterProvider struct {
triplepb.UnimplementedGreeterServer
}
diff --git a/samples/dubbogo/simple/triple/server/protobuf/api/samples_api.pb.go b/samples/dubbogo/simple/triple/server/protobuf/api/samples_api.pb.go
index e6c897ce..5dc90940 100644
--- a/samples/dubbogo/simple/triple/server/protobuf/api/samples_api.pb.go
+++ b/samples/dubbogo/simple/triple/server/protobuf/api/samples_api.pb.go
@@ -29,7 +29,7 @@ import (
)
import (
- proto "github.com/golang/protobuf/proto"
+ proto "github.com/golang/protobuf/proto" //nolint
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
diff --git a/samples/dubbogo/simple/uri/server/app/user.go b/samples/dubbogo/simple/uri/server/app/user.go
index 9a11d63a..6df7c480 100644
--- a/samples/dubbogo/simple/uri/server/app/user.go
+++ b/samples/dubbogo/simple/uri/server/app/user.go
@@ -27,6 +27,7 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
+
hessian "github.com/apache/dubbo-go-hessian2"
)
diff --git a/samples/grpc/pixiu/conf.yaml b/samples/grpc/pixiu/conf.yaml
index 84fdad57..42044f78 100644
--- a/samples/grpc/pixiu/conf.yaml
+++ b/samples/grpc/pixiu/conf.yaml
@@ -47,7 +47,6 @@ static_resources:
- socket_address:
address: 127.0.0.1
port: 50001
- protocol_type: "GRPC"
shutdown_config:
timeout: "60s"
step_timeout: "10s"
diff --git a/samples/grpc/test/pixiu_test.go b/samples/grpc/test/pixiu_test.go
index f75de9e8..d72fb486 100644
--- a/samples/grpc/test/pixiu_test.go
+++ b/samples/grpc/test/pixiu_test.go
@@ -27,6 +27,7 @@ import (
import (
"github.com/stretchr/testify/assert"
+
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
diff --git a/samples/xds/local-control-panel/server/app/go.sum b/samples/xds/local-control-panel/server/app/go.sum
index 0a1a75e6..785857f4 100644
--- a/samples/xds/local-control-panel/server/app/go.sum
+++ b/samples/xds/local-control-panel/server/app/go.sum
@@ -113,7 +113,7 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
-github.com/cch123/supermonkey v1.0.0/go.mod h1:d5jXTCyG6nu/pu0vYmoC0P/l0eBGesv3oQQ315uNBOA=
+github.com/cch123/supermonkey v1.0.1/go.mod h1:d5jXTCyG6nu/pu0vYmoC0P/l0eBGesv3oQQ315uNBOA=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
diff --git a/samples/xds/local-control-panel/server/app/main.go b/samples/xds/local-control-panel/server/app/main.go
index d931f907..eb5c850e 100644
--- a/samples/xds/local-control-panel/server/app/main.go
+++ b/samples/xds/local-control-panel/server/app/main.go
@@ -20,10 +20,13 @@ package main
import (
"context"
"flag"
+ "os"
+)
+
+import (
"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
"github.com/envoyproxy/go-control-plane/pkg/server/v3"
"github.com/envoyproxy/go-control-plane/pkg/test/v3"
- "os"
)
var (
diff --git a/samples/xds/local-control-panel/server/app/resoruce_pixiu2.go b/samples/xds/local-control-panel/server/app/resoruce_pixiu2.go
index 10083aff..4ce4c740 100644
--- a/samples/xds/local-control-panel/server/app/resoruce_pixiu2.go
+++ b/samples/xds/local-control-panel/server/app/resoruce_pixiu2.go
@@ -18,12 +18,14 @@
package main
import (
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds"
- pixiupb "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds/model"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
+ pixiupb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
+
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
"github.com/envoyproxy/go-control-plane/pkg/cache/types"
"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
+
"google.golang.org/protobuf/types/known/anypb"
)
diff --git a/samples/xds/local-control-panel/server/app/resource_pixiu.go b/samples/xds/local-control-panel/server/app/resource_pixiu.go
index 8adce5b3..df8c49e0 100644
--- a/samples/xds/local-control-panel/server/app/resource_pixiu.go
+++ b/samples/xds/local-control-panel/server/app/resource_pixiu.go
@@ -18,18 +18,23 @@
package main
import (
- "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
- "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds"
- pixiupb "github.com/dubbogo/dubbo-go-pixiu-filter/pkg/xds/model"
+ "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds"
+ pixiupb "github.com/dubbo-go-pixiu/pixiu-api/pkg/xds/model"
+
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
"github.com/envoyproxy/go-control-plane/pkg/cache/types"
"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
+
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/structpb"
structpb2 "google.golang.org/protobuf/types/known/structpb"
)
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+)
+
var httpManagerConfigYaml = `
route_config:
routes:
@@ -92,9 +97,9 @@ func makeListeners() *pixiupb.PixiuExtensionListeners {
Address: &pixiupb.Address{
SocketAddress: &pixiupb.SocketAddress{
Address: "0.0.0.0",
- Port: 8888,
+ Port: 8081,
},
- Name: "http_8888",
+ Name: "http_8081",
},
FilterChain: makeHttpFilter(),
},
diff --git a/samples/xds/local-control-panel/server/app/server.go b/samples/xds/local-control-panel/server/app/server.go
index a85ec05d..87ec66f1 100644
--- a/samples/xds/local-control-panel/server/app/server.go
+++ b/samples/xds/local-control-panel/server/app/server.go
@@ -20,22 +20,24 @@ package main
import (
"context"
"fmt"
- extensionpb "github.com/envoyproxy/go-control-plane/envoy/service/extension/v3"
"log"
"net"
"time"
+)
- "google.golang.org/grpc"
- "google.golang.org/grpc/keepalive"
-
+import (
clusterservice "github.com/envoyproxy/go-control-plane/envoy/service/cluster/v3"
discoverygrpc "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
endpointservice "github.com/envoyproxy/go-control-plane/envoy/service/endpoint/v3"
+ extensionpb "github.com/envoyproxy/go-control-plane/envoy/service/extension/v3"
listenerservice "github.com/envoyproxy/go-control-plane/envoy/service/listener/v3"
routeservice "github.com/envoyproxy/go-control-plane/envoy/service/route/v3"
runtimeservice "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3"
secretservice "github.com/envoyproxy/go-control-plane/envoy/service/secret/v3"
"github.com/envoyproxy/go-control-plane/pkg/server/v3"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/keepalive"
)
const (