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

Ftr: Context support #330

Merged
merged 5 commits into from
Jan 21, 2020
Merged

Ftr: Context support #330

merged 5 commits into from
Jan 21, 2020

Conversation

flycash
Copy link
Member

@flycash flycash commented Jan 20, 2020

What this PR does:

Adding context.Context to three methods: Filter.Invoke, Filter.OnResponse and Invoker.Invoke.

When we want to support some feature, like tracing and A/B test, we need to transfer the context between client and server. So we should refactor our interfaces to support the context argument.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@codecov-io
Copy link

codecov-io commented Jan 20, 2020

Codecov Report

Merging #330 into develop will increase coverage by 0.18%.
The diff coverage is 73.23%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #330      +/-   ##
===========================================
+ Coverage    66.06%   66.25%   +0.18%     
===========================================
  Files          122      122              
  Lines         7562     7562              
===========================================
+ Hits          4996     5010      +14     
+ Misses        2074     2060      -14     
  Partials       492      492
Impacted Files Coverage Δ
registry/protocol/protocol.go 81.73% <0%> (ø) ⬆️
filter/filter_impl/generic_filter.go 67.69% <0%> (ø) ⬆️
protocol/invoker.go 0% <0%> (ø) ⬆️
common/proxy/proxy_factory/default.go 20.96% <0%> (ø) ⬆️
...rotocol/protocolwrapper/protocol_filter_wrapper.go 51.42% <0%> (ø) ⬆️
cluster/cluster_impl/broadcast_cluster_invoker.go 80% <100%> (ø) ⬆️
cluster/cluster_impl/available_cluster_invoker.go 73.33% <100%> (ø) ⬆️
cluster/cluster_impl/failover_cluster_invoker.go 72.34% <100%> (ø) ⬆️
cluster/cluster_impl/failfast_cluster_invoker.go 71.42% <100%> (ø) ⬆️
protocol/jsonrpc/jsonrpc_invoker.go 100% <100%> (ø) ⬆️
... and 23 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 f8d1ecd...29c195d. Read the comment docs.

@flycash
Copy link
Member Author

flycash commented Jan 20, 2020

I've tested it end to end.

@flycash flycash changed the title [WIP] Ftr: Context support Ftr: Context support Jan 20, 2020
@AlexStocks
Copy link
Contributor

maybe u should use context.Background() instead of context.Todo()

Copy link
Member

@zouyx zouyx left a comment

Choose a reason for hiding this comment

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

would you like to add at least one test case to verify your idea?

filter/filter.go Show resolved Hide resolved
filter/filter_impl/echo_filter.go Show resolved Hide resolved
filter/filter_impl/tps_limit_filter.go Show resolved Hide resolved
protocol/invoker.go Show resolved Hide resolved
@flycash
Copy link
Member Author

flycash commented Jan 21, 2020

Actually, I don't need to add UT because I just add a new parameter and make sure that there is not any compiling error.
I've changed the context.TODO() to context.Backgroud()

Copy link
Contributor

@hxmhlt hxmhlt left a comment

Choose a reason for hiding this comment

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

Hard working & good job!

Copy link
Member

@zouyx zouyx left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member Author

@flycash flycash left a comment

Choose a reason for hiding this comment

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

All imports fixed

@flycash flycash merged commit 1fa4bf6 into apache:develop Jan 21, 2020
@flycash flycash mentioned this pull request Mar 17, 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