dubbo-go icon indicating copy to clipboard operation
dubbo-go copied to clipboard

dubbo-go路由接口的改进

Open FinalT opened this issue 2 years ago • 5 comments

在dubbo-go中,PriorityRouter接口定义了URL()方法,但在其实现类中,并没有能够传入这个url的方法,导致实现类的URL()方法只能返回空值,,而在工厂接口PriorityRouterFactory中,定义了NewPriorityRouter() 方法,并且在注释中描述了会带着url创建PriorityRouter,但参数中并没有url。

我认为在接口PriorityRouterFactory的NewPriorityRouter()这个方法中,应该加上url这个参数,并且在后续开发其他规则路由中,也需要这个url获取路由规则以及其他参数。

// dubbo-go/cluster/router/router.go

// PriorityRouterFactory creates priority router with url
type PriorityRouterFactory interface {
	// NewPriorityRouter creates router instance with URL
	NewPriorityRouter() (PriorityRouter, error)
}

// PriorityRouter routes with priority
type PriorityRouter interface {
	// Route Determine the target invokers list.
	Route([]protocol.Invoker, *common.URL, protocol.Invocation) []protocol.Invoker

	// URL Return URL in router
	URL() *common.URL

	// Priority Return Priority in router
	// 0 to ^int(0) is better
	Priority() int64

	// Notify the router the invoker list
	Notify(invokers []protocol.Invoker)
}

FinalT avatar Mar 29 '23 16:03 FinalT

I'm a newbie, can I try it?

tobehardest avatar Mar 30 '23 16:03 tobehardest

Can I have a try?

xiaolibuzai-ovo avatar Jun 06 '23 17:06 xiaolibuzai-ovo

Can I have a try?

Of course

FinalT avatar Jun 07 '23 01:06 FinalT

thinks,Please assign it to me and I will finish it as soon as possible

xiaolibuzai-ovo avatar Jun 07 '23 02:06 xiaolibuzai-ovo

@FinalT 先跟 @georgehao [hao hong fan] 沟通下,不要上来着急改。这块代码是火山,很容易改出问题。

AlexStocks avatar Jun 07 '23 03:06 AlexStocks