Skip to content

Commit

Permalink
feat:support nacos-address server endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun committed Jun 30, 2024
1 parent 3ff7b93 commit 0565bfe
Show file tree
Hide file tree
Showing 25 changed files with 1,387 additions and 1,056 deletions.
6 changes: 3 additions & 3 deletions cache/service/router_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (rc *routingConfigCache) Name() string {
}

func (rc *routingConfigCache) ListRouterRule(service, namespace string) []*model.ExtendRouterConfig {
routerRules := rc.bucket.listEnableRules(service, namespace)
routerRules := rc.bucket.listEnableRules(service, namespace, true)
ret := make([]*model.ExtendRouterConfig, 0, len(routerRules))
for level := range routerRules {
items := routerRules[level]
Expand All @@ -132,7 +132,7 @@ func (rc *routingConfigCache) GetRouterConfigV2(id, service, namespace string) (
return nil, nil
}

routerRules := rc.bucket.listEnableRules(service, namespace)
routerRules := rc.bucket.listEnableRules(service, namespace, true)
revisions := make([]string, 0, 8)
rulesV2 := make([]*apitraffic.RouteRule, 0, len(routerRules))
for level := range routerRules {
Expand Down Expand Up @@ -167,7 +167,7 @@ func (rc *routingConfigCache) GetRouterConfig(id, service, namespace string) (*a
return nil, nil
}

routerRules := rc.bucket.listEnableRules(service, namespace)
routerRules := rc.bucket.listEnableRules(service, namespace, false)
inBounds, outBounds, revisions := rc.convertV2toV1(routerRules, service, namespace)
revision, err := types.CompositeComputeRevision(revisions)
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions cache/service/router_rule_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (b *routeRuleBucket) size() int {

// listEnableRules Inquire the routing rules of the V2 version through the service name,
// and perform some filtering according to the Predicate
func (b *routeRuleBucket) listEnableRules(service, namespace string) map[routingLevel][]*model.ExtendRouterConfig {
func (b *routeRuleBucket) listEnableRules(service, namespace string, enableFullMatch bool) map[routingLevel][]*model.ExtendRouterConfig {
ret := make(map[routingLevel][]*model.ExtendRouterConfig)
tmpRecord := map[string]struct{}{}

Expand Down Expand Up @@ -338,11 +338,13 @@ func (b *routeRuleBucket) listEnableRules(service, namespace string) map[routing
level2 = append(level2, handler(b.level2Rules[inBound][namespace], inBound)...)
ret[level2RoutingV2] = level2

// Query Level3 level routing-v2 rules
level3 := make([]*model.ExtendRouterConfig, 0, 4)
level3 = append(level3, handler(b.level3Rules[outBound], outBound)...)
level3 = append(level3, handler(b.level3Rules[inBound], inBound)...)
ret[level3RoutingV2] = level3
if enableFullMatch {
// Query Level3 level routing-v2 rules
level3 := make([]*model.ExtendRouterConfig, 0, 4)
level3 = append(level3, handler(b.level3Rules[outBound], outBound)...)
level3 = append(level3, handler(b.level3Rules[inBound], inBound)...)
ret[level3RoutingV2] = level3
}
return ret
}

Expand Down
5 changes: 5 additions & 0 deletions common/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const (
MaxDbCircuitbreakerComment = 1024
MaxDbCircuitbreakerOwner = 1024
MaxDbCircuitbreakerVersion = 32

MaxPlatformIDLength = 32
MaxPlatformNameLength = 128
MaxPlatformDomainLength = 1024
MaxPlatformQPS = 65535
)

var resourceNameRE = regexp.MustCompile("^[0-9A-Za-z-./:_]+$")
Expand Down
1 change: 0 additions & 1 deletion service/client_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func (s *Server) DeregisterInstance(ctx context.Context, req *apiservice.Instanc

// ReportServiceContract report client service interface info
func (s *Server) ReportServiceContract(ctx context.Context, req *apiservice.ServiceContract) *apiservice.Response {
ctx = context.WithValue(ctx, utils.ContextIsFromClient, true)
cacheData := s.caches.ServiceContract().Get(ctx, &model.ServiceContract{
Namespace: req.GetNamespace(),
Service: req.GetService(),
Expand Down
6 changes: 0 additions & 6 deletions service/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,6 @@ func (svr *Server) pluginInitialize() {
log.Warnf("Not Found History Log Plugin")
}

// 获取限流插件
svr.ratelimit = plugin.GetRatelimit()
if svr.ratelimit == nil {
log.Warnf("Not found Ratelimit Plugin")
}

subscriber := plugin.GetDiscoverEvent()
if subscriber == nil {
log.Warnf("Not found DiscoverEvent Plugin")
Expand Down
Loading

0 comments on commit 0565bfe

Please sign in to comment.