-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
dubbo_proxy: Adds a routing matcher for the Dubbo protocol. #5571
Conversation
|
||
// A list of individual Dubbo filters that make up the filter chain for requests made to the | ||
// Dubbo proxy. Order matters as the filters are processed sequentially. For backwards | ||
// compatibility, if no thrift_filters are specified, a default Dubbo router filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thrift -> dubbo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// * For range [-10,0), route will match for header value -1, but not for 0, | ||
// "somestring", 10.9, | ||
// "-1somestring" | ||
envoy.type.Int64Range range_match = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the type of the parameter is not an integer, is this range matching useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, The type definition is not needed. I delete it.
syntax = "proto3"; | ||
|
||
package envoy.config.filter.network.dubbo_proxy.v2alpha1; | ||
option java_package = "io.envoyproxy.envoy.config.filter.network.thrift_proxy.v2alpha1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
package envoy.extensions.filters.network.dubbo_proxy.v2alpha1; | ||
option java_package = "io.envoyproxy.envoy.extensions.filters.network.dubbo_proxy.v2alpha1"; | ||
package envoy.config.filter.network.dubbo_proxy.v2alpha1; | ||
option java_package = "io.envoyproxy.envoy.config.filter.network.thrift_proxy.v2alpha1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
namespace Router { | ||
|
||
bool Utility::isContainWildcard(const std::string& input) { | ||
return (input.find('*') != std::string::npos) || (input.find('?') != std::string::npos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://en.wikipedia.org/wiki/Glob_(programming)
Do you want to support the full wildcard? or you just want to support the *
and ?
?, I suggest that it is the same as the virtual host, only *
is supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dubbo routing matches need to support wildcard * and ?.
const envoy::config::filter::network::dubbo_proxy::v2alpha1::Route& route) | ||
: cluster_name_(route.route().cluster()) { | ||
for (const auto& header_map : route.match().headers()) { | ||
config_headers_.push_back(header_map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
namespace DubboProxy { | ||
namespace Router { | ||
|
||
class Utility { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer using an anonymous namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved utility class to utiliti.h file.
public Logger::Loggable<Logger::Id::dubbo> { | ||
public: | ||
RouteEntryImplBase(const envoy::config::filter::network::dubbo_proxy::v2alpha1::Route& route); | ||
virtual ~RouteEntryImplBase() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
ParameterRouteEntryImpl::ParameterData::ParameterData(const ParameterConfig& config) { | ||
index_ = config.index(); | ||
type_ = config.type(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is it used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type_ is useless. I deleted it.
RouteConstSharedPtr MultiRouteMatcher::route(const MessageMetadata& metadata, | ||
uint64_t random_value) const { | ||
for (const auto& route_matcher : route_matcher_list_) { | ||
ENVOY_LOG(debug, "dubbo route matcher: route matching failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
route matching failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry,i delete it.
|
||
RouteConstSharedPtr RouteMatcher::route(const MessageMetadata& metadata, | ||
uint64_t random_value) const { | ||
if (interface_name_ == metadata.service_name() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can interface_name and service_name be unified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been uniformly named service name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some nits.
@lizan
I passed the first round of review
test/extensions/filters/network/dubbo_proxy/route_matcher_test.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/network/dubbo_proxy/router/route_matcher.cc
Outdated
Show resolved
Hide resolved
source/extensions/filters/network/dubbo_proxy/router/route_matcher.cc
Outdated
Show resolved
Hide resolved
/retest |
🔨 rebuilding |
api/envoy/config/filter/network/dubbo_proxy/v2alpha1/dubbo_proxy.proto
Outdated
Show resolved
Hide resolved
api/envoy/config/filter/network/dubbo_proxy/v2alpha1/route.proto
Outdated
Show resolved
Hide resolved
api/envoy/config/filter/network/dubbo_proxy/v2alpha1/route.proto
Outdated
Show resolved
Hide resolved
api/envoy/config/filter/network/dubbo_proxy/v2alpha1/route.proto
Outdated
Show resolved
Hide resolved
api/envoy/config/filter/network/dubbo_proxy/v2alpha1/route.proto
Outdated
Show resolved
Hide resolved
@lizan Is there any other code review opinion ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, sorry for the confusion
using envoy::config::filter::network::dubbo_proxy::v2alpha1::RouteMatch; | ||
|
||
// Verify configuration rules. | ||
MessageUtil::validate(config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry I misunderstood so ignore my previous comment, you don't need this...
|
||
private: | ||
const Matchers::StringMatcher method_name_; | ||
absl::optional<std::shared_ptr<ParameterRouteEntryImpl>> parameter_route_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to differentiate nullopt vs nullptr? If no simple shared_ptr should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@lizan Is there any other code review opinion ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
package envoy.config.filter.network.dubbo_proxy.v2alpha1; | ||
option java_package = "io.envoyproxy.envoy.config.filter.network.dubbo_proxy.v2alpha1"; | ||
option java_multiple_files = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you merge master? I think this line is no longer needed (will fail master CI)
1838398
to
33ae24e
Compare
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
… utility class. Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
33ae24e
to
bbe4d86
Compare
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gengleilei in the future, please do not rebase and force-push, instead you can merge master. force-push will make it harder to follow review history.
@lizan Ok, thank you for reminder. |
…xy#5571) *Description*: Adds a routing matcher for the Dubbo protocol. envoyproxy#3998 *Risk Level*: low *Testing*: unit test *Docs Changes*: N/A *Release Notes*: N/A this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com> Signed-off-by: Dan Zhang <danzh@google.com>
…xy#5571) *Description*: Adds a routing matcher for the Dubbo protocol. envoyproxy#3998 *Risk Level*: low *Testing*: unit test *Docs Changes*: N/A *Release Notes*: N/A this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
…xy#5571) *Description*: Adds a routing matcher for the Dubbo protocol. envoyproxy#3998 *Risk Level*: low *Testing*: unit test *Docs Changes*: N/A *Release Notes*: N/A this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com> Signed-off-by: Fred Douglas <fredlas@google.com>
// Dubbo proxy. Order matters as the filters are processed sequentially. For backwards | ||
// compatibility, if no dubbo_filters are specified, a default Dubbo router filter | ||
// (`envoy.filters.dubbo.router`) is used. | ||
repeated DubboFilter dubbo_filters = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gengleilei I am new to dubbo, my question is how to setup individual Dubbo filters
?
I can not find any other supported filters except envoy.filters.dubbo.router
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can refer to the Router (router_impl.h), you need to implement DubboFilters: : DecoderFilter interface, yaml configuration is as follows:
stat_prefix: ingress
route_config:
name: local_route
dubbo_filters:
- name: envoy.filters.dubbo.mock_filter
config:
"@type": type.googleapis.com/google.protobuf.Struct
value:
name: test_service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IC, this is for advanced users, need to hack into the envoy code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Filter based extension mechanism is similar to HTTP. Dubbo does not define a unique Filter mechanism. of course, if you have good suggestions, we are also very welcome to build together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this error, any idea?
[2019-08-06 02:35:19.872][27][error][dubbo] [external/envoy/source/extensions/filters/network/dubbo_proxy/conn_manager.cc:132] [C35] dubbo error: invalid dubbo mes
sage magic number 20186
Description: Adds a routing matcher for the Dubbo protocol.
Risk Level: low
Testing: unit test
Docs Changes: N/A
Release Notes: N/A
[Optional Fixes #Issue] #3998
[Optional Deprecated:]
this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy