Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix router rule parsing log error #2720

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cluster/router/condition/dynamic_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ func (s *ServiceRouter) Notify(invokers []protocol.Invoker) {
logger.Errorf("Failed to query condition rule, key=%s, err=%v", key, err)
return
}
if value == "" {
logger.Infof("Condition rule is empty, key=%s", key)
return
}
s.Process(&config_center.ConfigChangeEvent{Key: key, Value: value, ConfigType: remoting.EventTypeAdd})
}

Expand Down Expand Up @@ -370,6 +374,10 @@ func (a *ApplicationRouter) Notify(invokers []protocol.Invoker) {
logger.Errorf("Failed to query condition rule, key=%s, err=%v", key, err)
return
}
if value == "" {
logger.Infof("Condition rule is empty, key=%s", key)
return
}
a.Process(&config_center.ConfigChangeEvent{Key: key, Value: value, ConfigType: remoting.EventTypeUpdate})
}
}
Expand Down
7 changes: 4 additions & 3 deletions cluster/router/condition/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package condition

import (
"dubbo.apache.org/dubbo-go/v3/cluster/router"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/common/extension"
)

func init() {
// TODO(finalt) Temporarily removed until fixed
//extension.SetRouterFactory(constant.ConditionServiceRouterFactoryKey, NewServiceConditionRouterFactory)
//extension.SetRouterFactory(constant.ConditionAppRouterFactoryKey, NewAppConditionRouterFactory)
extension.SetRouterFactory(constant.ConditionServiceRouterFactoryKey, NewServiceConditionRouterFactory)
extension.SetRouterFactory(constant.ConditionAppRouterFactoryKey, NewAppConditionRouterFactory)
}

// ServiceRouteFactory router factory
Expand Down
5 changes: 3 additions & 2 deletions cluster/router/tag/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package tag

import (
"dubbo.apache.org/dubbo-go/v3/cluster/router"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/common/extension"
)

func init() {
Expand All @@ -27,8 +29,7 @@ func init() {
and cause warning if config center is empty.
User can import this package and config config center to use tag router.
*/
// TODO(finalt) Temporarily removed until fixed
//extension.SetRouterFactory(constant.TagRouterFactoryKey, NewTagRouterFactory)
extension.SetRouterFactory(constant.TagRouterFactoryKey, NewTagRouterFactory)
}

// RouteFactory router factory
Expand Down
4 changes: 4 additions & 0 deletions cluster/router/tag/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ func (p *PriorityRouter) Notify(invokers []protocol.Invoker) {
logger.Errorf("query router rule fail,key=%s,err=%v", key, err)
return
}
if value == "" {
logger.Infof("router rule is empty,key=%s", key)
return
}
p.Process(&config_center.ConfigChangeEvent{Key: key, Value: value, ConfigType: remoting.EventTypeAdd})
}

Expand Down
2 changes: 1 addition & 1 deletion protocol/triple/triple_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (ti *TripleInvoker) Invoke(ctx context.Context, invocation protocol.Invocat
func mergeAttachmentToOutgoing(ctx context.Context, inv protocol.Invocation) (context.Context, error) {
// Todo(finalt) Temporarily solve the problem that the timeout time is not valid
if timeout, ok := inv.GetAttachment(constant.TimeoutKey); ok {
ctx = context.WithValue(ctx, "dubbo.timeout.key", timeout)
ctx = context.WithValue(ctx, tri.TimeoutKey{}, timeout)
}
for key, valRaw := range inv.Attachments() {
if str, ok := valRaw.(string); ok {
Expand Down
4 changes: 3 additions & 1 deletion protocol/triple/triple_protocol/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"time"
)

type TimeoutKey struct{}

// Client is a reusable, concurrency-safe client for a single procedure.
// Depending on the procedure's type, use the CallUnary, CallClientStream,
// CallServerStream, or CallBidiStream method.
Expand Down Expand Up @@ -282,7 +284,7 @@ func applyDefaultTimeout(ctx context.Context, timeout time.Duration) (context.Co

// Todo(finalt) Temporarily solve the problem that the timeout time is not valid
if !ok {
timeoutVal := ctx.Value("dubbo.timeout.key")
timeoutVal := ctx.Value(TimeoutKey{})
if timeoutVal != nil {
if s, exist := timeoutVal.(string); exist && s != "" {
if newTimeout, err := time.ParseDuration(s); err == nil {
Expand Down
Loading