Loadbalance round robin#66
Loadbalance round robin#66zonghaishang merged 9 commits intoapache:masterfrom zonghaishang:loadbalance_round_robin
Conversation
| "sync" | ||
| "sync/atomic" | ||
| "time" | ||
| ) |
There was a problem hiding this comment.
这里手工format一下代码,看下其他的包的import规范
|
|
||
| complete = 0 | ||
| updating = 1 | ||
| ) |
| return invokers[0] | ||
| } | ||
|
|
||
| key := invokers[0].GetUrl().Path + "." + invocation.MethodName() |
There was a problem hiding this comment.
用invokers[0].GetUrl().Key() + "." + invocation.MethodName() 是否可以,version/group 字段也要作为key字段考虑进来
cluster/loadbalance/round_robin.go
Outdated
| extension.SetLoadbalance(roundRobin, NewRoundRobinLoadBalance) | ||
| } | ||
|
|
||
| type roundRobinLoadBalance 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.
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.
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.
上面这块代码,可以统一放进一个 var {
} 里面
cluster/loadbalance/round_robin.go
Outdated
| now := time.Now() | ||
|
|
||
| for _, invoker := range invokers { | ||
|
|
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.