Skip to content

Commit

Permalink
Merge pull request apache#2 from apache/develop
Browse files Browse the repository at this point in the history
update
  • Loading branch information
maxingg authored May 29, 2022
2 parents a241420 + 97ebae2 commit 925b746
Show file tree
Hide file tree
Showing 117 changed files with 1,271 additions and 494 deletions.
1 change: 0 additions & 1 deletion .github/workflows/go.sum

This file was deleted.

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
37 changes: 16 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,43 @@ module github.com/apache/dubbo-go-pixiu
go 1.15

require (
dubbo.apache.org/dubbo-go/v3 v3.0.1-0.20220107110037-4496cef73dba
dubbo.apache.org/dubbo-go/v3 v3.0.2-0.20220519062747-f6405fa79d5c
github.com/MicahParks/keyfunc v1.0.0
github.com/Shopify/sarama v1.19.0
github.com/alibaba/sentinel-golang v1.0.4
github.com/apache/dubbo-getty v1.4.7-rc2
github.com/apache/dubbo-getty v1.4.8
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
github.com/dubbogo/triple v1.1.7
github.com/dubbogo/gost v1.11.25
github.com/dubbogo/grpc-go v1.42.9
github.com/dubbogo/triple v1.1.8
github.com/envoyproxy/go-control-plane v0.10.1
github.com/frankban/quicktest v1.11.3 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/gin-gonic/gin v1.7.4
github.com/gin-gonic/gin v1.7.7
github.com/go-errors/errors v1.0.1
github.com/go-playground/assert/v2 v2.0.1
github.com/go-resty/resty/v2 v2.7.0
github.com/gogo/protobuf v1.3.2
github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9
github.com/golang-jwt/jwt/v4 v4.1.0
github.com/golang/mock v1.4.4
github.com/golang/mock v1.5.0
github.com/golang/protobuf v1.5.2
github.com/jhump/protoreflect v1.9.0
github.com/mercari/grpc-http-proxy v0.1.2
github.com/mitchellh/mapstructure v1.4.3
github.com/nacos-group/nacos-sdk-go v1.0.9
github.com/mitchellh/mapstructure v1.5.0
github.com/nacos-group/nacos-sdk-go v1.1.1
github.com/opentrx/seata-golang/v2 v2.0.5
github.com/pkg/errors v0.9.1
github.com/prometheus/common v0.29.0 // indirect
github.com/shirou/gopsutil v3.21.3+incompatible // indirect
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.1
go.etcd.io/etcd/api/v3 v3.5.1
go.opentelemetry.io/otel v1.6.1
go.etcd.io/etcd/api/v3 v3.5.4
go.opentelemetry.io/otel v1.7.0
go.opentelemetry.io/otel/exporters/jaeger v1.6.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.6.1
Expand All @@ -49,17 +48,13 @@ require (
go.opentelemetry.io/otel/sdk v1.6.1
go.opentelemetry.io/otel/sdk/export/metric v0.21.0
go.opentelemetry.io/otel/sdk/metric v0.21.0
go.opentelemetry.io/otel/trace v1.6.1
go.uber.org/zap v1.19.1
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
go.opentelemetry.io/otel/trace v1.7.0
go.uber.org/zap v1.21.0
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
golang.org/x/net v0.0.0-20211209124913-491a49abca63
golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0 // indirect
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.28.0
gopkg.in/yaml.v2 v2.4.0
vimagination.zapto.org/byteio v0.0.0-20200222190125-d27cba0f0b10
vimagination.zapto.org/memio v0.0.0-20200222190306-588ebc67b97d // indirect
)

//github.com/go-logr/logr => github.com/go-logr/logr v1.0.0
replace k8s.io/apimachinery => k8s.io/apimachinery v0.23.5
)
233 changes: 68 additions & 165 deletions go.sum

Large diffs are not rendered by default.

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
42 changes: 31 additions & 11 deletions pkg/adapter/springcloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const (

Nacos = "nacos"
Zookeeper = "zookeeper"
Consul = "consul"
)

func init() {
Expand Down Expand Up @@ -73,15 +72,28 @@ type (
Registry *model.RemoteConfig `yaml:"registry" json:"registry" default:"registry"`
FreshInterval time.Duration `yaml:"freshInterval" json:"freshInterval" default:"freshInterval"`
Services []string `yaml:"services" json:"services" default:"services"`
// todo configuration the discovery config, like `zookeeper.discovery.root = "/services"`
//Discovery *model.DiscoveryConfig `yaml:"discovery" json:"discovery" default:"discovery"`
// SubscribePolicy subscribe config,
// - adapting : if there is no any Services (App) names, fetch All services from registry center
// - definitely : fetch services by the config Services (App) names
SubscribePolicy string `yaml:"subscribe-policy" json:"subscribe-policy" default:"adapting"`
}

Service struct {
Name string
}

SubscribePolicy int
)

const (
Adapting SubscribePolicy = iota
Definitely
)

func (sp SubscribePolicy) String() string {
return [...]string{"adapting", "definitely"}[sp]
}

// Kind return plugin kind
func (p *CloudPlugin) Kind() string {
return Kind
Expand All @@ -94,26 +106,24 @@ func (p *CloudPlugin) CreateAdapter(ad *model.Adapter) (adapter.Adapter, error)

// Start start the adapter
func (a *CloudAdapter) Start() {

// do not block the main goroutine
// init get all service instance
err := a.firstFetch()
if err != nil {
logger.Errorf("init fetch service fail", err.Error())
//return
}

// background sync service instance from remote
err = a.backgroundSyncPeriod()
if err != nil {
logger.Errorf("init periodicity fetch service task fail", err.Error())
//return
}

// watch then fetch is more safety for consistent but there is background fresh mechanism
err = a.watch()
if err != nil {
logger.Errorf("init watch the register fail", err.Error())
//return
}
}

Expand All @@ -136,7 +146,6 @@ func (a *CloudAdapter) Apply() error {
switch strings.ToLower(a.cfg.Registry.Protocol) {
case Nacos:
sd, err = nacos.NewNacosServiceDiscovery(a.cfg.Services, a.cfg.Registry, a)
case Consul:
case Zookeeper:
sd, err = zookeeper.NewZKServiceDiscovery(a.cfg.Services, a.cfg.Registry, a)
default:
Expand Down Expand Up @@ -208,10 +217,18 @@ func (a *CloudAdapter) fetchServiceByConfig() ([]servicediscovery.ServiceInstanc
var instances []servicediscovery.ServiceInstance
var err error
// if configure specific services, then fetch those service instance only
if len(a.cfg.Services) > 0 {
instances, err = a.sd.QueryServicesByName(a.cfg.Services)
if a.subscribeServiceDefinitely() {
if len(a.cfg.Services) > 0 {
instances, err = a.sd.QueryServicesByName(a.cfg.Services)
} else {
logger.Warnf("No any Service(App) need Subscribe, config the Service(App) Names or make the `subscribe-policy: adapting` pls.")
}
} else {
instances, err = a.sd.QueryAllServices()
if len(a.cfg.Services) > 0 {
instances, err = a.sd.QueryServicesByName(a.cfg.Services)
} else {
instances, err = a.sd.QueryAllServices()
}
}

if err != nil {
Expand Down Expand Up @@ -347,8 +364,11 @@ func (a *CloudAdapter) stop() error {
err := a.sd.Unsubscribe()
if err != nil {
logger.Errorf("unsubscribe registry fail ", err.Error())
//return err
}
close(a.stopChan)
return nil
}

func (a *CloudAdapter) subscribeServiceDefinitely() bool {
return strings.EqualFold(a.cfg.SubscribePolicy, Definitely.String())
}
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
4 changes: 2 additions & 2 deletions pkg/client/dubbo/dubbo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ import (
dg "dubbo.apache.org/dubbo-go/v3/config"
"dubbo.apache.org/dubbo-go/v3/config/generic"
_ "dubbo.apache.org/dubbo-go/v3/filter/generic"
_ "dubbo.apache.org/dubbo-go/v3/filter/gshutdown"
_ "dubbo.apache.org/dubbo-go/v3/filter/graceful_shutdown"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/local"
"dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"

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
Loading

0 comments on commit 925b746

Please sign in to comment.