Skip to content

Commit

Permalink
Lds basic (#417)
Browse files Browse the repository at this point in the history
* 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 <mark4z.vip@gmail.com>
  • Loading branch information
mark4z and mark4z authored May 10, 2022
1 parent 2b24d46 commit bcc678d
Show file tree
Hide file tree
Showing 89 changed files with 535 additions and 167 deletions.
2 changes: 1 addition & 1 deletion cmd/pixiu/pixiu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/dubboregistry/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion pkg/adapter/dubboregistry/registry/nacos/service_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/dubboregistry/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/adapter/dubboregistry/registry/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

import (
"dubbo.apache.org/dubbo-go/v3/common"

"github.com/dubbogo/go-zookeeper/zk"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/dubboregistry/registry/zookeeper/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/dubboregistry/registrycenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

import (
"github.com/dubbogo/go-zookeeper/zk"

gzk "github.com/dubbogo/gost/database/kv/zk"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

import (
"github.com/dubbogo/go-zookeeper/zk"

gzk "github.com/dubbogo/gost/database/kv/zk"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/dubbo/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/dubbo/dubbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/dubbo/dubbo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/dubbo/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/dubbo/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/http/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/http/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pkg/common/extension/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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{}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/common/grpc/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/http/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/http/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/mock/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/api_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
28 changes: 16 additions & 12 deletions pkg/config/xds/cds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
})
}
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit bcc678d

Please sign in to comment.