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

thrift: implement Twitter protocol variant #4363

Merged
merged 10 commits into from
Sep 18, 2018

Conversation

zuercher
Copy link
Member

@zuercher zuercher commented Sep 6, 2018

Implements the Twitter variant of the Thrift binary protocol,
as implemented by the finagle library.

Risk Level: low
Testing: unit tests
Docs Changes: updated API docs
Release Notes: n/a

Signed-off-by: Stephan Zuercher [email protected]

Implements the Twitter variant of the Thrift binary protocol,
as implemented by the finagle library.

*Risk Level*: low
*Testing*: unit tests
*Docs Changes*: updated API docs
*Release Notes*: n/a

Signed-off-by: Stephan Zuercher <[email protected]>
@zuercher
Copy link
Member Author

zuercher commented Sep 6, 2018

@brirams, @rgs1, @fishcakez if you'd like to have a look

Copy link
Member

@rgs1 rgs1 left a comment

Choose a reason for hiding this comment

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

generally lgtm, left a few comments. thanks!

source/extensions/filters/network/thrift_proxy/metadata.h Outdated Show resolved Hide resolved
ClientId(const ThriftStructValue& value) {
for (const auto& field : value.fields()) {
if (field->fieldId() == NameFieldId) {
name_ = field->getValue().getValueTyped<std::string>();
Copy link
Member

Choose a reason for hiding this comment

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

should we log when we see more than one client id (e.g.: name_ gets set more than once)? also, should we document why we keep the last occurence?

Copy link
Member Author

Choose a reason for hiding this comment

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

There isn't any provision for sending multiple client ids. The loop here is over the fields of the ClientId struct (which has only ever had a single field, with default requiredness). The struct itself is optional as well.

rgs1
rgs1 previously approved these changes Sep 11, 2018
Copy link
Member

@rgs1 rgs1 left a comment

Choose a reason for hiding this comment

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

thanks!

brian-pane
brian-pane previously approved these changes Sep 12, 2018
@zuercher
Copy link
Member Author

@htuch do you have time to take a quick pass at this in the next couple of days?

@zuercher zuercher dismissed stale reviews from brian-pane and rgs1 via 4a049f1 September 12, 2018 22:19
Signed-off-by: Stephan Zuercher <[email protected]>
Signed-off-by: Stephan Zuercher <[email protected]>
brian-pane
brian-pane previously approved these changes Sep 14, 2018
@htuch
Copy link
Member

htuch commented Sep 14, 2018

@zuercher if you can hold off until Mon, I'll do this then.

@htuch htuch self-assigned this Sep 14, 2018
@zuercher
Copy link
Member Author

Sure. Will fix the merge conflict in the meantime.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

I'm going to defer completely to @rgs1 and @brian-pane on the correctness here, a quick pass revealed a few nits. Feel free to ship when they are resolved as you think best.

@@ -91,14 +91,27 @@ void ConnectionManager::dispatch() {
void ConnectionManager::sendLocalReply(MessageMetadata& metadata, const DirectResponse& response) {
Buffer::OwnedImpl buffer;

response.encode(metadata, *protocol_, buffer);
DirectResponse::ResponseType result = response.encode(metadata, *protocol_, buffer);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: const

@@ -41,7 +45,19 @@ bool AutoProtocolImpl::readMessageBegin(Buffer::Instance& buffer, MessageMetadat

uint16_t version = buffer.peekBEInt<uint16_t>();
if (BinaryProtocolImpl::isMagic(version)) {
setType(ProtocolType::Binary);
// 12 bytes is the minimum length for message-begin in the binary protocol.
if (buffer.length() < 12) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: raw 12 here feels icky, unclear how it relates to following code and its expectations. It might not be much clearer to add a constant at top of file, but for your consideration.

const SpanList& spans() const { return spans_; }

/**
* @return SpanList* a pointer to a mutable list of Spans
Copy link
Member

Choose a reason for hiding this comment

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

Nit: prefer Envoy style SpanList& unless this can be null.

F(endpointStruct, Endpoint) \
F(upgradeReplyStruct, UpgradeReply)

#define REQUEST_HEADER_FIELD_NAMES(F) \
Copy link
Member

Choose a reason for hiding this comment

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

Why not make all of these a const singleton?

Signed-off-by: Stephan Zuercher <[email protected]>
Signed-off-by: Stephan Zuercher <[email protected]>
@zuercher
Copy link
Member Author

@htuch I've addressed the review comments, but I still need a maintainer to actually click the button.

@zuercher zuercher merged commit 21c6d13 into envoyproxy:master Sep 18, 2018
@zuercher zuercher deleted the stephan/ttwitter-protocol branch September 18, 2018 17:55
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