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

Loadbalance round robin #66

Merged
merged 9 commits into from
Jun 13, 2019
Merged

Loadbalance round robin #66

merged 9 commits into from
Jun 13, 2019

Conversation

zonghaishang
Copy link
Member

No description provided.

@CLAassistant
Copy link

CLAassistant commented Jun 3, 2019

CLA assistant check
All committers have signed the CLA.

"sync"
"sync/atomic"
"time"
)
Copy link
Contributor

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
)
Copy link
Contributor

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()
Copy link
Contributor

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字段考虑进来

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要的

extension.SetLoadbalance(roundRobin, NewRoundRobinLoadBalance)
}

type roundRobinLoadBalance struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空 struct,一行内写完代码,不要搞成两行

}

func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go里面没有第一行空行的

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go里面没有第一行空行的, 这句话什么意思? @AlexStocks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go里面没有第一行空行的, 这句话什么意思? @AlexStocks

我的意思是,一般的go项目里,没见过函数有第一行是空行的规矩。这个应该是java 的吧?

func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker {

count := len(invokers)
if invokers == nil || count == 0 {
Copy link
Contributor

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

maxCurrentWeight := int64(math.MinInt64)
var selectedInvoker protocol.Invoker
var selectedWeightRobin weightedRoundRobin
now := time.Now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面这块代码,可以统一放进一个 var {
} 里面

now := time.Now()

for _, invoker := range invokers {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不要有空行

@codecov-io
Copy link

codecov-io commented Jun 12, 2019

Codecov Report

Merging #66 into master will decrease coverage by 0.3%.
The diff coverage is 3.38%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
cluster/loadbalance/round_robin.go 3.38% <3.38%> (ø)
config/registry_config.go 85% <0%> (-2.5%) ⬇️
registry/zookeeper/listener.go 45.27% <0%> (-1%) ⬇️
registry/zookeeper/zk_client.go 54.96% <0%> (-0.34%) ⬇️
protocol/dubbo/client.go 70% <0%> (-0.14%) ⬇️
registry/directory/directory.go 78.09% <0%> (ø) ⬆️
cluster/cluster_impl/mock_cluster.go 0% <0%> (ø) ⬆️
common/url.go 72.34% <0%> (ø) ⬆️
registry/protocol/protocol.go 76.53% <0%> (ø) ⬆️
cluster/cluster_impl/failover_cluster_invoker.go 80.95% <0%> (ø) ⬆️
... and 41 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51406b3...d081c07. Read the comment docs.

@zonghaishang zonghaishang merged commit 28d3c8d into apache:master Jun 13, 2019
LaurenceLiZhixin pushed a commit to LaurenceLiZhixin/dubbo-go that referenced this pull request Jul 17, 2021
fix: enhance filter samples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants