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

Add attribute method into Invocation and RpcInvocation #537

Merged
merged 3 commits into from
May 28, 2020

Conversation

cvictory
Copy link
Contributor

Some parameter need to be used in the internal process. For example we need calculate the serialize type and store into attribute. If we don't store it and this serialize value is used by some function or method , we must calculate it in every function.

protocol/invocation/rpcinvocation.go Show resolved Hide resolved
func (r *RPCInvocation) AttributeByKey(key string, defaultValue interface{}) interface{} {
r.lock.RLock()
defer r.lock.RUnlock()
if r.attributes == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

after init this map in newRPCInvocation, u can delete this if condition clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two methods about NewRPCInvocation . Another one is NewRPCInvocationWithOptions. We cannot make it init it well.

Copy link
Member

Choose a reason for hiding this comment

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

I think we could init the attributes in NewRPCInvocationWithOptions too. The attribute map is empty. What's your concern?

Copy link
Contributor

Choose a reason for hiding this comment

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

@flycash can not agree with u more.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cvictory pls improve NewRPCInvocationWithOptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added WithAttributes function for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cvictory pls delete WithAttributes and modify NewRPCInvocationWithOptions

@codecov-commenter
Copy link

codecov-commenter commented May 24, 2020

Codecov Report

Merging #537 into develop will decrease coverage by 0.74%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #537      +/-   ##
===========================================
- Coverage    67.20%   66.46%   -0.75%     
===========================================
  Files          174      184      +10     
  Lines         9261     9712     +451     
===========================================
+ Hits          6224     6455     +231     
- Misses        2432     2617     +185     
- Partials       605      640      +35     
Impacted Files Coverage Δ
registry/zookeeper/registry.go 46.15% <0.00%> (-9.30%) ⬇️
protocol/dubbo/listener.go 57.52% <0.00%> (-5.38%) ⬇️
common/url.go 65.83% <0.00%> (-5.33%) ⬇️
protocol/dubbo/pool.go 76.81% <0.00%> (-4.47%) ⬇️
config_center/nacos/impl.go 71.08% <0.00%> (-4.31%) ⬇️
config_center/apollo/impl.go 82.71% <0.00%> (-4.30%) ⬇️
remoting/zookeeper/facade.go 70.27% <0.00%> (-4.02%) ⬇️
config/provider_config.go 55.88% <0.00%> (-3.50%) ⬇️
filter/filter_impl/hystrix_filter.go 68.64% <0.00%> (-3.39%) ⬇️
registry/nacos/registry.go 58.42% <0.00%> (-3.37%) ⬇️
... and 64 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 8a3c02c...41c9d89. Read the comment docs.

func (r *RPCInvocation) AttributeByKey(key string, defaultValue interface{}) interface{} {
r.lock.RLock()
defer r.lock.RUnlock()
if r.attributes == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think we could init the attributes in NewRPCInvocationWithOptions too. The attribute map is empty. What's your concern?

Copy link
Contributor

@fangyincheng fangyincheng left a comment

Choose a reason for hiding this comment

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

LGTM

@cvictory cvictory changed the base branch from master to develop May 28, 2020 01:50
@AlexStocks AlexStocks merged commit 39a84d9 into apache:develop May 28, 2020
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