-
Notifications
You must be signed in to change notification settings - Fork 932
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
Loadbalance round robin #66
Loadbalance round robin #66
Conversation
"sync" | ||
"sync/atomic" | ||
"time" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里手工format一下代码,看下其他的包的import规范
|
||
complete = 0 | ||
updating = 1 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dubbogo const 的规范为全部大写.
return invokers[0] | ||
} | ||
|
||
key := invokers[0].GetUrl().Path + "." + invocation.MethodName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用invokers[0].GetUrl().Key() + "." + invocation.MethodName() 是否可以,version/group 字段也要作为key字段考虑进来
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要的
cluster/loadbalance/round_robin.go
Outdated
extension.SetLoadbalance(roundRobin, NewRoundRobinLoadBalance) | ||
} | ||
|
||
type roundRobinLoadBalance struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空 struct,一行内写完代码,不要搞成两行
cluster/loadbalance/round_robin.go
Outdated
} | ||
|
||
func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go里面没有第一行空行的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go里面没有第一行空行的, 这句话什么意思? @AlexStocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go里面没有第一行空行的, 这句话什么意思? @AlexStocks
我的意思是,一般的go项目里,没见过函数有第一行是空行的规矩。这个应该是java 的吧?
cluster/loadbalance/round_robin.go
Outdated
func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { | ||
|
||
count := len(invokers) | ||
if invokers == nil || count == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if count == 0 判断即可,就算是 nil,其长度也为 0
cluster/loadbalance/round_robin.go
Outdated
maxCurrentWeight := int64(math.MinInt64) | ||
var selectedInvoker protocol.Invoker | ||
var selectedWeightRobin weightedRoundRobin | ||
now := time.Now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上面这块代码,可以统一放进一个 var {
} 里面
cluster/loadbalance/round_robin.go
Outdated
now := time.Now() | ||
|
||
for _, invoker := range invokers { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不要有空行
Codecov Report
@@ Coverage Diff @@
## master #66 +/- ##
==========================================
- Coverage 67.03% 66.73% -0.31%
==========================================
Files 49 50 +1
Lines 3428 3469 +41
==========================================
+ Hits 2298 2315 +17
- Misses 900 924 +24
Partials 230 230
Continue to review full report at Codecov.
|
fix: enhance filter samples.
No description provided.