Skip to content

dubbo_proxy: Redefine DecoderFilter interface and add EncoderFilter support#7118

Merged
lizan merged 7 commits intoenvoyproxy:masterfrom
gengleilei:feature-redefine-decoder-and-support-encoder
Jul 15, 2019
Merged

dubbo_proxy: Redefine DecoderFilter interface and add EncoderFilter support#7118
lizan merged 7 commits intoenvoyproxy:masterfrom
gengleilei:feature-redefine-decoder-and-support-encoder

Conversation

@gengleilei
Copy link
Copy Markdown
Contributor

@gengleilei gengleilei commented May 31, 2019

Description: Redefine DecoderFilter interface and add EncoderFilter support
Risk Level: low
Testing: unit test
Docs Changes: N/A
Release Notes: N/A
[Optional Fixes #Issue]
[Optional Deprecated:]

Redefining DecoderFilter is mainly for 2 reasons:

  1. The original interface is not clear and complicated for the user, for example, the user needs to understand the meaning of transportBegin, transportEnd, messageBegin, messageEnd, transferHeaderTo, transferBodyTo, and we want to minimize this cost, so we decided to provide only one after internal discussion: onMessageDecoded interface.
  2. We used to have an internal implementation version and submitted a version to the community, but this obviously wastes a lot of development resources, so we decided to merge the two versions, mainly based on the open source version.

As mentioned above, we merged the internal and open source versions. EncoderFilter is currently needed internally, such as the retry mechanism. we will consider adding more features to Dubbo later, similar to HTTP, so EncoderFilter is also necessary. we want to bring more features to users around Dubbo.

@gengleilei gengleilei requested a review from lizan as a code owner May 31, 2019 11:48
@jmarantz
Copy link
Copy Markdown
Contributor

@lizan the author requested a review from you, but do you prefer to have a non-senior maintainer read it first?

@gengleilei drive-by comment: this meaty PR probably deserves more content in the description. Why is the DecoderFilter being redefined, and why is there now a need for an EncoderFilter?

@lizan
Copy link
Copy Markdown
Member

lizan commented May 31, 2019

/assign @zyfjeff
Can you take a first pass?

@lizan lizan requested a review from zyfjeff May 31, 2019 13:36
@gengleilei gengleilei force-pushed the feature-redefine-decoder-and-support-encoder branch from 6a505aa to 128e382 Compare June 3, 2019 02:36
@gengleilei
Copy link
Copy Markdown
Contributor Author

@jmarantz sorry, I've added some more detailed instructions on redefining DecoderFilter and supporting EncoderFilter.

@zyfjeff
Copy link
Copy Markdown
Member

zyfjeff commented Jun 6, 2019

@lizan I'm sorry, recently a little busy, I will be review recently

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where use?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ActiveMessageDecoderFilter and ActiveMessagerEncodeFilter will use dual-filter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why remove

Downstream half closed, does it need to wait for the response of the upstream?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry, the code was deleted by mistake while merging, I have restored it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fix comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fix comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add EncoderFilter unit tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@stale
Copy link
Copy Markdown

stale bot commented Jun 13, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jun 13, 2019
@gengleilei gengleilei force-pushed the feature-redefine-decoder-and-support-encoder branch from 128e382 to 223c493 Compare June 17, 2019 16:43
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Jun 17, 2019
@gengleilei
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🤷‍♀️ nothing to rebuild.

🐱

Caused by: a #7118 (comment) was created by @gengleilei.

see: more, trace.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why doesn't care about the return value for onData here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At present, when Decoder processes data, it either finishes processing or needs to wait until the data is entered, so there is no stop.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix comments

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

total_size += size;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ASSERT(context)? Why do you want to take raw pointer here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry,there is no need to convert, this part is left out when modify the code.

@zyfjeff
Copy link
Copy Markdown
Member

zyfjeff commented Jun 20, 2019

/wait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can't append data to a buffer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, at present, I haven't thought of any scenarios that require append data, and I can let go of this restriction if necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

try catch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove static_cast, don't use raw point here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use class? this class is not a simple POD type, also contains some virtual method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because it's simple, you don't need to actively add public declarations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think here should use the class, this is not a simple POD type. Can't go to easy access to the data members of the break of object-oriented rules

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

=default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use a raw point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@gengleilei gengleilei force-pushed the feature-redefine-decoder-and-support-encoder branch from 7c266f8 to e84dda6 Compare June 26, 2019 13:34
@zyfjeff
Copy link
Copy Markdown
Member

zyfjeff commented Jun 27, 2019

Please merge the master to resolve conflicts

@zyfjeff zyfjeff removed their assignment Jun 27, 2019
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

route_matcher_ = Router::NamedRouteMatcherConfigFactory::getFactory(type).createRouteMatcher( config.route_config(), context);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const ContextSharedPtr?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

const cannot be used here because it changes the value of message_origin_buffer_ in the Context, as used in the onMessageDecoded function:
upstream_request_buffer_.move(ctx->message_origin_data(), ctx->message_size());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove static_cast ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It cannot be deleted here because the static_cast is needed to complete the conversion of the base class reference to the derived class reference, which will fail to compile after deletion.

Copy link
Copy Markdown
Member

@zyfjeff zyfjeff Jul 1, 2019

Choose a reason for hiding this comment

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

Downcasting, Should use dynamic_cast and judge whether the result is nullptr after the cast, rather than use staic_cast directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove static_cast ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ditto

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ASSERT(itor != routeMatcherNameMap.end())
return itor->second;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ASSERT(itor != protocolSerializerTypeNameMap.end())
return itor->second;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ASSERT(itor != serializerTypeNameMap.end())
return itor->second;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ASSERT(itor != protocolTypeNameMap.end())
return itor->second;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not use SerializationType

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To be compatible with the internal HSF protocol, both HSF and Dubbo define SerializationType, but with different values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove optional? The method name why will not exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@zyfjeff
Copy link
Copy Markdown
Member

zyfjeff commented Jun 27, 2019

/ wait

@gengleilei gengleilei force-pushed the feature-redefine-decoder-and-support-encoder branch from e84dda6 to 550ae32 Compare June 27, 2019 05:54
@zyfjeff
Copy link
Copy Markdown
Member

zyfjeff commented Jul 1, 2019

/ wait

zyfjeff
zyfjeff previously approved these changes Jul 1, 2019
Copy link
Copy Markdown
Member

@zyfjeff zyfjeff left a comment

Choose a reason for hiding this comment

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

LGTM, @lizan Passed the first review

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>
@gengleilei gengleilei force-pushed the feature-redefine-decoder-and-support-encoder branch from 88a08f1 to a5ce22a Compare July 8, 2019 03:00
@gengleilei
Copy link
Copy Markdown
Contributor Author

@lizan Please help to review, thanks.

ASSERT(encoder_filter_action_ != nullptr);

if (!local_response_sent_) {
std::list<ActiveMessageEncoderFilterPtr>::iterator entry = commonEncodePrefix(filter, state);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

put this in the for statement below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Buffer::Instance& buffer) const override {
ASSERT(buffer.length() == 0);

ENVOY_LOG(debug, "err {}", what());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

make the log message more descriptive?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

~RpcResultImpl() override = default;

bool hasException() const override { return has_exception_; }
void SetException(bool has_exception) { has_exception_ = has_exception; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

setException

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

virtual ResponseStatus responseStatus() const PURE;
virtual ~RpcResult() = default;
virtual bool hasException() const PURE;
virtual bool hasValue() const PURE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

where is this used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sorry,hasValue function is not used, I have deleted it.

@lizan lizan added the waiting label Jul 9, 2019
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
@lizan lizan merged commit e442ba5 into envoyproxy:master Jul 15, 2019
@lizan lizan mentioned this pull request Jul 15, 2019
zuercher pushed a commit that referenced this pull request Jul 16, 2019
Fix merge race of #7118 and #7447

Risk Level: Low
Testing: n/a
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
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.

4 participants