-
Notifications
You must be signed in to change notification settings - Fork 4.1k
THRIFT-5322: Implement TConfiguration in Go library #2296
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
Conversation
|
|
||
| // NewTHeaderProtocolFactoryWithProtocolID creates a factory for THeader with | ||
| // given protocol ID. | ||
| func NewTHeaderProtocolFactoryWithProtocolID(protoID THeaderProtocolID) (TProtocolFactory, error) { |
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.
note that this is a breaking change from a previous version on master branch. however it is not a breaking change from 0.13.0.
c047f4e to
173ea94
Compare
|
LGTM from a quick read but I won't be able to test until the new year. |
Jens-G
left a comment
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.
Good work!
LGTM overall. I only did a code review, did not run any tests on it. Only minor/cosmetic issues found.
| } | ||
| size := binary.BigEndian.Uint32(buf) | ||
| if size < 0 || size > p.maxLength { | ||
| if size < 0 || size > uint32(p.cfg.GetMaxFrameSize()) { |
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 code was there before but I really wonder when size will become negative on an uint32?
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.
Before p.maxLength actually has the type of uint32 instead of int32.
To become negative when converting to int32 the uint32 value needs to be at least 2GB (MaxInt32 is 1<<31-1). I'm not sure how much do we really care about that use case. If we do care about it I can change the types of MaxMessageSize and MaxFrameSize both from int32 to uint32.
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 very much doubt this is a legitimate possibility, int32 seems fine to me.
lib/go/thrift/header_protocol.go
Outdated
| return p.protocol.Skip(ctx, fieldType) | ||
| } | ||
|
|
||
| // SetTConfiguration implemtns TConfigurationSetter. |
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.
... implements ... (there is more than one instance of this typo)
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.
Thanks. Fixed.
173ea94 to
1dbf3ac
Compare
|
I moved timeouts from Please take another look. |
2e93211 to
36ae85f
Compare
dcelasun
left a comment
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.
Finally had a chance to play around with this. I've tested framed transport and binary protocol, works as expected.
Thanks for working on this :)
| } | ||
| size := binary.BigEndian.Uint32(buf) | ||
| if size < 0 || size > p.maxLength { | ||
| if size < 0 || size > uint32(p.cfg.GetMaxFrameSize()) { |
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 very much doubt this is a legitimate possibility, int32 seems fine to me.
lib/go/thrift/header_protocol.go
Outdated
| // NewTHeaderProtocol creates a new THeaderProtocol from the underlying | ||
| // transport with default protocol ID. | ||
| // NewTHeaderProtocolConf creates a new THeaderProtocol from the underlying | ||
| // transport with gien TConfiguration. |
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.
| // transport with gien TConfiguration. | |
| // transport with given TConfiguration. |
baad75e to
af0664c
Compare
Client: go Define TConfiguration following the spec, and also move the following configurations scattered around different TTransport/TProtocol into it: - connect and socket timeouts for TSocket and TSSLSocket - tls config for TSSLSocket - max frame size for TFramedTransport - strict read and strict write for TBinaryProtocol - proto id for THeaderTransport Also add TConfiguration support for the following and their factories: - THeaderTransport and THeaderProtocol - TBinaryProtocol - TCompactProtocol - TFramedTransport - TSocket - TSSLSocket Also define TConfigurationSetter interface for easier TConfiguration propagation between wrapped TTransports/TProtocols , and add implementations to the following for propagation (they don't use anything from TConfiguration themselves): - StreamTransport - TBufferedTransport - TDebugProtocol - TJSONProtocol - TSimpleJSONProtocol - TZlibTransport TConfigurationSetter are not implemented by the factories of the "propagation only" TTransports/TProtocols, if they have a factory. For those use cases, TTransportFactoryConf and TProtocolFactoryConf are provided to wrap a factory with the ability to propagate TConfiguration. Also add simple sanity check for TBinaryProtocol and TCompactProtocol's ReadString and ReadBinary functions. Currently it only report error if the header length is larger than MaxMessageSize configured in TConfiguration, for simplicity.
af0664c to
fd53d7a
Compare
Client: go This fixes a bug introduced in #2296, that we mixed the preferred proto id and the detected proto id, which was a bad idea. This change separates them, so when we propagate TConfiguration, we only change the preferred one, which will only be used for new connections, and leave the detected one from existing connections untouched.
Client: go This fixes a bug introduced in apache#2296, that we mixed the preferred proto id and the detected proto id, which was a bad idea. This change separates them, so when we propagate TConfiguration, we only change the preferred one, which will only be used for new connections, and leave the detected one from existing connections untouched.
Client: go This fixes a bug introduced in apache#2296, that we mixed the preferred proto id and the detected proto id, which was a bad idea. This change separates them, so when we propagate TConfiguration, we only change the preferred one, which will only be used for new connections, and leave the detected one from existing connections untouched. Also add a test for it.
Client: go This fixes a bug introduced in #2296, that we mixed the preferred proto id and the detected proto id, which was a bad idea. This change separates them, so when we propagate TConfiguration, we only change the preferred one, which will only be used for new connections, and leave the detected one from existing connections untouched. Also add a test for it.
Client: go
Define TConfiguration following the spec, and also move the following
configurations scattered around different TTransport/TProtocol into it:
Also add TConfiguration support for the following and their factories:
Also define TConfigurationSetter interface for easier TConfiguration
propagation between wrapped TTransports/TProtocols , and add
implementations to the following for propagation
(they don't use anything from TConfiguration themselves):
TConfigurationSetter are not implemented by the factories of the
"propagation only" TTransports/TProtocols, if they have a factory. For
those use cases, TTransportFactoryConf and TProtocolFactoryConf are
provided to wrap a factory with the ability to propagate TConfiguration.
Also add simple sanity check for TBinaryProtocol and TCompactProtocol's
ReadString and ReadBinary functions. Currently it only report error if
the header length is larger than MaxMessageSize configured in
TConfiguration, for simplicity.