Skip to content

Commit

Permalink
update:
Browse files Browse the repository at this point in the history
Former-commit-id: f2caafa
  • Loading branch information
PhilYue committed Sep 13, 2021
1 parent 5c532b2 commit c75f49b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
8 changes: 8 additions & 0 deletions configs/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static_resources:
route:
cluster: "test-dubbo"
cluster_not_found_response_code: 505
dynamic: true
http_filters:
- name: dgp.filter.http.apiconfig
config:
Expand Down Expand Up @@ -84,6 +85,13 @@ static_resources:
adapters:
- name: "dgp.adapter.springcloud"
config:
services:
SPRING-CLOUD-PRODUCER:
id: SPRING-CLOUD-PRODUCER # 注册中心的服务名
name: SPRING-CLOUD-PRODUCER # 服务名
prefix: /scp # router 前缀
strip-prefix: true # 代理请求时移除前缀 rm /scp
otherConfig: "pixiu"
registries:
"eureka":
protocol: "eureka"
Expand Down
1 change: 0 additions & 1 deletion pkg/adapter/springcloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func (a *CloudAdapter) Start() {
go func() {

// init SpringCloud Manager for control initialize
//cloudManager := SpringCloudManager(a.boot)
cloudManager := NewSpringCloudManager(&SpringCloudConfig{boot: a.boot})

cloudManager.Start()
Expand Down
33 changes: 32 additions & 1 deletion pkg/adapter/springcloud/sc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/apache/dubbo-go-pixiu/pkg/adapter/springcloud/discovery"
"github.com/apache/dubbo-go-pixiu/pkg/logger"
"github.com/apache/dubbo-go-pixiu/pkg/model"
"github.com/apache/dubbo-go-pixiu/pkg/server"
)

// SpringCloudConfig SpringCloud that life cycle configuration
Expand Down Expand Up @@ -45,6 +46,35 @@ type scManager struct {
Stop func()
}

func (m *scManager) initCluster() {
endpoint := &model.Endpoint{}
endpoint.ID = "spring-cloud-producer" // 192.168.0.105:spring-cloud-producer:9000
endpoint.Address = model.SocketAddress{
Address: "192.168.0.105",
Port: 9000,
}
cluster := &model.Cluster{}
cluster.Name = "spring-cloud-producer"
cluster.Lb = model.Rand
cluster.Endpoints = []*model.Endpoint{
endpoint,
}
// add cluster into manager
cm := server.GetClusterManager()
cm.AddCluster(cluster)

// transform into route
routeMatch := model.RouterMatch{
Prefix: "/scp",
}
routeAction := model.RouteAction{
Cluster: "spring-cloud-producer",
}
route := &model.Router{Match: routeMatch, Route: routeAction}

server.GetRouterManager().AddRouter(route)
}

// load remote registry : nacos, consul...
func loadRouterByRemoteConfig() {

Expand Down Expand Up @@ -80,6 +110,7 @@ func NewSpringCloudManager(config *SpringCloudConfig) *scManager {
scConfig: config,
Start: func() *scManager {
manager.initAll()
manager.initRouter()
return manager
},
initAll: func() {
Expand Down Expand Up @@ -111,7 +142,7 @@ func NewSpringCloudManager(config *SpringCloudConfig) *scManager {
//resources
},
initRouter: func() {

manager.initCluster()
},
getServiceInfoById: func(serviceId string) {

Expand Down
7 changes: 4 additions & 3 deletions pkg/model/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ func (r *Router) MatchRouter(req *http2.Request) bool {
return true
}

if r.Match.matchMethod(req) {
return true
}
// pi 这地方 match method 可能需要调整,当前逻辑是只要为空就会返回true
//if r.Match.matchMethod(req) {
// return true
//}

if r.Match.matchHeader(req) {
return true
Expand Down

0 comments on commit c75f49b

Please sign in to comment.