Skip to content
Snippets Groups Projects
Commit edd99f59 authored by LaurenceLiZhixin's avatar LaurenceLiZhixin
Browse files

fix: range

parent e5d53ca4
No related branches found
No related tags found
No related merge requests found
...@@ -83,8 +83,7 @@ conditions: ...@@ -83,8 +83,7 @@ conditions:
appRouteURL := getAppRouteURL(routerKey) appRouteURL := getAppRouteURL(routerKey)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
appRouter, err := NewAppRouter(appRouteURL, notify) appRouter, err := NewAppRouter(appRouteURL, notify)
...@@ -140,8 +139,7 @@ conditions: ...@@ -140,8 +139,7 @@ conditions:
appRouteURL := getAppRouteURL(routerKey) appRouteURL := getAppRouteURL(routerKey)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
appRouter, err := NewAppRouter(appRouteURL, notify) appRouter, err := NewAppRouter(appRouteURL, notify)
...@@ -188,8 +186,7 @@ conditions: ...@@ -188,8 +186,7 @@ conditions:
appRouteURL := getAppRouteURL(routerKey) appRouteURL := getAppRouteURL(routerKey)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
appRouter, err := NewAppRouter(appRouteURL, notify) appRouter, err := NewAppRouter(appRouteURL, notify)
......
...@@ -134,8 +134,7 @@ func TestRoute_matchWhen(t *testing.T) { ...@@ -134,8 +134,7 @@ func TestRoute_matchWhen(t *testing.T) {
rule := base64.URLEncoding.EncodeToString([]byte("=> host = 1.2.3.4")) rule := base64.URLEncoding.EncodeToString([]byte("=> host = 1.2.3.4"))
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
router, _ := newConditionRouterFactory().NewPriorityRouter(getRouteUrl(rule), notify) router, _ := newConditionRouterFactory().NewPriorityRouter(getRouteUrl(rule), notify)
...@@ -171,8 +170,7 @@ func TestRoute_matchWhen(t *testing.T) { ...@@ -171,8 +170,7 @@ func TestRoute_matchWhen(t *testing.T) {
func TestRoute_matchFilter(t *testing.T) { func TestRoute_matchFilter(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -212,8 +210,7 @@ func TestRoute_matchFilter(t *testing.T) { ...@@ -212,8 +210,7 @@ func TestRoute_matchFilter(t *testing.T) {
func TestRoute_methodRoute(t *testing.T) { func TestRoute_methodRoute(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("getFoo"), invocation.WithParameterTypes([]reflect.Type{}), invocation.WithArguments([]interface{}{})) inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("getFoo"), invocation.WithParameterTypes([]reflect.Type{}), invocation.WithArguments([]interface{}{}))
...@@ -241,8 +238,7 @@ func TestRoute_methodRoute(t *testing.T) { ...@@ -241,8 +238,7 @@ func TestRoute_methodRoute(t *testing.T) {
func TestRoute_ReturnFalse(t *testing.T) { func TestRoute_ReturnFalse(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
url, _ := common.NewURL("") url, _ := common.NewURL("")
...@@ -259,8 +255,7 @@ func TestRoute_ReturnFalse(t *testing.T) { ...@@ -259,8 +255,7 @@ func TestRoute_ReturnFalse(t *testing.T) {
func TestRoute_ReturnEmpty(t *testing.T) { func TestRoute_ReturnEmpty(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -277,8 +272,7 @@ func TestRoute_ReturnEmpty(t *testing.T) { ...@@ -277,8 +272,7 @@ func TestRoute_ReturnEmpty(t *testing.T) {
func TestRoute_ReturnAll(t *testing.T) { func TestRoute_ReturnAll(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -303,8 +297,7 @@ func TestRoute_HostFilter(t *testing.T) { ...@@ -303,8 +297,7 @@ func TestRoute_HostFilter(t *testing.T) {
url3, _ := common.NewURL(fmt.Sprintf(factoryDubboFormat, localIP)) url3, _ := common.NewURL(fmt.Sprintf(factoryDubboFormat, localIP))
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
invoker1 := NewMockInvoker(url1, 1) invoker1 := NewMockInvoker(url1, 1)
...@@ -324,8 +317,7 @@ func TestRoute_HostFilter(t *testing.T) { ...@@ -324,8 +317,7 @@ func TestRoute_HostFilter(t *testing.T) {
func TestRoute_Empty_HostFilter(t *testing.T) { func TestRoute_Empty_HostFilter(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -349,8 +341,7 @@ func TestRoute_Empty_HostFilter(t *testing.T) { ...@@ -349,8 +341,7 @@ func TestRoute_Empty_HostFilter(t *testing.T) {
func TestRoute_False_HostFilter(t *testing.T) { func TestRoute_False_HostFilter(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -374,8 +365,7 @@ func TestRoute_False_HostFilter(t *testing.T) { ...@@ -374,8 +365,7 @@ func TestRoute_False_HostFilter(t *testing.T) {
func TestRoute_Placeholder(t *testing.T) { func TestRoute_Placeholder(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -399,8 +389,7 @@ func TestRoute_Placeholder(t *testing.T) { ...@@ -399,8 +389,7 @@ func TestRoute_Placeholder(t *testing.T) {
func TestRoute_NoForce(t *testing.T) { func TestRoute_NoForce(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
...@@ -422,8 +411,7 @@ func TestRoute_NoForce(t *testing.T) { ...@@ -422,8 +411,7 @@ func TestRoute_NoForce(t *testing.T) {
func TestRoute_Force(t *testing.T) { func TestRoute_Force(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
localIP := common.GetLocalIp() localIP := common.GetLocalIp()
......
...@@ -60,8 +60,7 @@ func TestParseRule(t *testing.T) { ...@@ -60,8 +60,7 @@ func TestParseRule(t *testing.T) {
func TestNewConditionRouter(t *testing.T) { func TestNewConditionRouter(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
url, _ := common.NewURL(`condition://0.0.0.0:?application=mock-app&category=routers&force=true&priority=1&router=condition&rule=YSAmIGMgPT4gYiAmIGQ%3D`) url, _ := common.NewURL(`condition://0.0.0.0:?application=mock-app&category=routers&force=true&priority=1&router=condition&rule=YSAmIGMgPT4gYiAmIGQ%3D`)
......
...@@ -50,8 +50,7 @@ func TestConnCheckRouterRoute(t *testing.T) { ...@@ -50,8 +50,7 @@ func TestConnCheckRouterRoute(t *testing.T) {
defer protocol.CleanAllStatus() defer protocol.CleanAllStatus()
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
consumerURL, _ := common.NewURL(connCheck1001URL) consumerURL, _ := common.NewURL(connCheck1001URL)
......
...@@ -51,8 +51,7 @@ func TestHealthCheckRouterRoute(t *testing.T) { ...@@ -51,8 +51,7 @@ func TestHealthCheckRouterRoute(t *testing.T) {
defer protocol.CleanAllStatus() defer protocol.CleanAllStatus()
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
consumerURL, _ := common.NewURL(healthCheck1001URL) consumerURL, _ := common.NewURL(healthCheck1001URL)
...@@ -120,8 +119,7 @@ func TestNewHealthCheckRouter(t *testing.T) { ...@@ -120,8 +119,7 @@ func TestNewHealthCheckRouter(t *testing.T) {
defer protocol.CleanAllStatus() defer protocol.CleanAllStatus()
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
url, _ := common.NewURL(fmt.Sprintf(healthCheckDubboUrlFormat, healthCheckDubbo1010IP)) url, _ := common.NewURL(fmt.Sprintf(healthCheckDubboUrlFormat, healthCheckDubbo1010IP))
......
...@@ -41,8 +41,7 @@ func TestTagRouterFactoryNewRouter(t *testing.T) { ...@@ -41,8 +41,7 @@ func TestTagRouterFactoryNewRouter(t *testing.T) {
factory := NewTagRouterFactory() factory := NewTagRouterFactory()
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
tagRouter, e := factory.NewPriorityRouter(u1, notify) tagRouter, e := factory.NewPriorityRouter(u1, notify)
......
...@@ -121,8 +121,7 @@ func TestTagRouterPriority(t *testing.T) { ...@@ -121,8 +121,7 @@ func TestTagRouterPriority(t *testing.T) {
u1, err := common.NewURL(tagRouterTestUserConsumerTag) u1, err := common.NewURL(tagRouterTestUserConsumerTag)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
assert.Nil(t, err) assert.Nil(t, err)
...@@ -135,8 +134,7 @@ func TestTagRouterPriority(t *testing.T) { ...@@ -135,8 +134,7 @@ func TestTagRouterPriority(t *testing.T) {
func TestTagRouterRouteForce(t *testing.T) { func TestTagRouterRouteForce(t *testing.T) {
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
u1, e1 := common.NewURL(tagRouterTestUserConsumerTag) u1, e1 := common.NewURL(tagRouterTestUserConsumerTag)
...@@ -175,8 +173,7 @@ func TestTagRouterRouteNoForce(t *testing.T) { ...@@ -175,8 +173,7 @@ func TestTagRouterRouteNoForce(t *testing.T) {
assert.Nil(t, e1) assert.Nil(t, e1)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
tagRouter, e := NewTagRouter(u1, notify) tagRouter, e := NewTagRouter(u1, notify)
...@@ -244,8 +241,7 @@ func TestRouteBeijingInvoker(t *testing.T) { ...@@ -244,8 +241,7 @@ func TestRouteBeijingInvoker(t *testing.T) {
url, _ := common.NewURL(tagRouterTestBeijingUrl) url, _ := common.NewURL(tagRouterTestBeijingUrl)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
tagRouter, _ := NewTagRouter(url, notify) tagRouter, _ := NewTagRouter(url, notify)
...@@ -326,8 +322,7 @@ tags: ...@@ -326,8 +322,7 @@ tags:
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
tagRouter, err := NewTagRouter(url, notify) tagRouter, err := NewTagRouter(url, notify)
...@@ -397,8 +392,7 @@ func TestProcess(t *testing.T) { ...@@ -397,8 +392,7 @@ func TestProcess(t *testing.T) {
assert.Nil(t, err) assert.Nil(t, err)
notify := make(chan struct{}) notify := make(chan struct{})
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
tagRouter, e := NewTagRouter(u1, notify) tagRouter, e := NewTagRouter(u1, notify)
...@@ -420,8 +414,7 @@ tags: ...@@ -420,8 +414,7 @@ tags:
addresses: [192.168.1.3, 192.168.1.4] addresses: [192.168.1.3, 192.168.1.4]
` `
go func() { go func() {
for { for range notify {
<-notify
} }
}() }()
tagRouter.Process(&config_center.ConfigChangeEvent{Value: testYML, ConfigType: remoting.EventTypeAdd}) tagRouter.Process(&config_center.ConfigChangeEvent{Value: testYML, ConfigType: remoting.EventTypeAdd})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment