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

Impl: support extension of two urls comparison. #854

Merged
merged 7 commits into from
Dec 22, 2020

Conversation

cvictory
Copy link
Contributor

@cvictory cvictory commented Nov 7, 2020

support extension of two urls comparison.

Because the URL.IsEquals will consume some performance, you can define your own implements.

@AlexStocks AlexStocks requested review from beiwei30 and Patrick0308 and removed request for beiwei30 November 7, 2020 06:28
}

// Config default defaultURLComparator.
func init() {
Copy link
Member

Choose a reason for hiding this comment

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

Should be moved after the package declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove the file. Just use func instead of Interface.

package common

import (
"github.com/apache/dubbo-go/common/constant"
Copy link
Member

Choose a reason for hiding this comment

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

split pkg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove the file.


// default comparison implements
func (defaultURLComparator) CompareURLEqual(l *URL, r *URL, excludeParam ...string) bool {
return IsEquals(*l, *r, excludeParam...)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check l, r whether is nil? And if one of them is nil, I think we should return false.

But if both of them are nil, I am not sure whether we should return true.

Copy link
Contributor

Choose a reason for hiding this comment

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

@flycash 我们需要一个更系统性的 URL 改进方案,必须加锁确保安全,然后至少添加一个 Copy 函数,目前的实现很容易被人误用。

Copy link
Member

Choose a reason for hiding this comment

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

我的理解是,现在URL只有我们这种开发维护人员才会直接使用到。误用是指哪方面?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add some check in IsEquals func.

Comment on lines 24 to 26
type URLComparator interface {
CompareURLEqual(*URL, *URL, ...string) bool
}
Copy link
Contributor

Choose a reason for hiding this comment

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

May be a simple function is better?
like this var CompareURLEqualFunc(*URL, *URL, ...string) bool;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea !
Done.

@codecov-io
Copy link

codecov-io commented Dec 9, 2020

Codecov Report

Merging #854 (93932e1) into develop (04fa9b0) will increase coverage by 0.00%.
The diff coverage is 70.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #854   +/-   ##
========================================
  Coverage    60.20%   60.20%           
========================================
  Files          260      260           
  Lines        12886    12894    +8     
========================================
+ Hits          7758     7763    +5     
+ Misses        4170     4167    -3     
- Partials       958      964    +6     
Impacted Files Coverage Δ
registry/directory/directory.go 79.72% <0.00%> (ø)
common/url.go 61.60% <66.66%> (+1.98%) ⬆️
cluster/router/chain/chain.go 69.04% <100.00%> (-1.12%) ⬇️
remoting/kubernetes/listener.go 50.52% <0.00%> (-3.16%) ⬇️
remoting/getty/pool.go 68.72% <0.00%> (-0.89%) ⬇️

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 04fa9b0...93932e1. Read the comment docs.

@cvictory cvictory requested a review from zouyx December 9, 2020 06:26
@LaurenceLiZhixin
Copy link
Contributor

LGTM

common/url.go Outdated
return IsEquals(l, r, excludeParam...)
}

func init() {
Copy link
Member

Choose a reason for hiding this comment

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

move to the top of this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@zouyx zouyx added this to the v1.5.6 milestone Dec 22, 2020
@zouyx zouyx merged commit f734264 into apache:develop Dec 22, 2020
AlexStocks pushed a commit that referenced this pull request Apr 14, 2021
Impl: support extension of two urls comparison.
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.

9 participants