-
Notifications
You must be signed in to change notification settings - Fork 103
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
encoding/thrift: Add mechanisms to handle inbound requests via thriftrw's 'nowire' implementation #2084
Conversation
e1f115f
to
e78be5f
Compare
encoding/thrift/internal/observabilitytest/test/testserviceserver/server.go
Outdated
Show resolved
Hide resolved
encoding/thrift/internal/observabilitytest/test/testserviceserver/server.go
Outdated
Show resolved
Hide resolved
Some context on the discussion @witriew and I had about this, which, in Some of the decisions made in encoding/thrift, after a couple years of When Wit was designing the interfaces here, I suggested that since these were |
encoding/thrift/internal/observabilitytest/test/testserviceserver/server.go
Outdated
Show resolved
Hide resolved
body stream.Enveloper | ||
} | ||
|
||
var _ NoWireHandler = (*responseHandler)(nil) |
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.
Is there any chance to use a mock for NoWireHandler?
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.
Addendum to the previous comment: For objects with behavioral, mocks can be preferable if the behavior is non-trivial.
Alternatively, a test-only noWireHandlerFunc
type that allows test cases to write the behavior inline as needed is also a good option if the assertions aren't shared between the different cases.
type noWireHandlerFunc func(context.Context, *NoWireCall) (NoWireResponse, error)
func (f noWireHandlerFunc) HandleNoWire(ctx context.Context, nwc *NoWireCall) (NoWireResponse, error) {
return f(ctx, nwc)
}
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.
In the case of the NoWireHandler
stub, I wanted to ensure that the stuff thats passed into HandleNoWire
is what is expected. Since all of the calls here have effectively the same checks, it seems cleaner to have the stub that does all of this at once instead of repeating these checks for each of the mocks.
6cadf3a
to
13ea32e
Compare
c9d1ad3
to
b26373b
Compare
Okay, so this stack isn't green because of:
That's a result of thriftrw/thriftrw-go#532 — RequestReaders and Protocols are different interfaces now so the same object cannot be used for them. Given that this is a new code path, I don't see value in doing upgrade-protocol-to-requestreader dance and just having it be RequestReader-only: All stream based implementations must implement RequestReader. Going to update the PR stack with fixes. |
41afa2e
to
2aa54c0
Compare
Codecov Report
@@ Coverage Diff @@
## nowiredev #2084 +/- ##
=============================================
+ Coverage 87.58% 87.61% +0.03%
=============================================
Files 247 248 +1
Lines 13731 13772 +41
=============================================
+ Hits 12026 12067 +41
Misses 1325 1325
Partials 380 380
Continue to review full report at Codecov.
|
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 besides nits.
body stream.Enveloper | ||
} | ||
|
||
var _ NoWireHandler = (*responseHandler)(nil) |
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.
Addendum to the previous comment: For objects with behavioral, mocks can be preferable if the behavior is non-trivial.
Alternatively, a test-only noWireHandlerFunc
type that allows test cases to write the behavior inline as needed is also a good option if the assertions aren't shared between the different cases.
type noWireHandlerFunc func(context.Context, *NoWireCall) (NoWireResponse, error)
func (f noWireHandlerFunc) HandleNoWire(ctx context.Context, nwc *NoWireCall) (NoWireResponse, error) {
return f(ctx, nwc)
}
3bc1991
to
947a4c0
Compare
c390896
to
2b1cadd
Compare
947a4c0
to
97c57f6
Compare
2b1cadd
to
138ede4
Compare
97c57f6
to
86a7fb7
Compare
…nal/crossdock, and internal/examples Bump thriftrw-go to consume the new no-wire (streaming) implementation. Also stop using deprecated fields (except in tests) and regenerate all of the thriftrw relevant files.
4415d06
to
99eb629
Compare
…wire' implementaiton thriftrw's 'nowire' implementation (known as 'streaming' in the thriftrw context) is an alternative wire-compatible implementation of the Thrift protocol that bypasses the intermediate 'thriftrw.Wire' representation and 'streams' the protocol directly to the related objects. This provides the mechanisms to handle 'Call's made via the 'nowire' implementation instead of the existing 'Wire'-intermediary format. Doing so involved creating a new type, `thriftNoWireHandler`, that implements both a `transport.UnaryHandler` and a `transport.OnewayHandler`. These call into a new interface, `NoWireHandler` (which will be implemented by generated code, for each procedure), that understands how to unpack the request using thriftrw's 'nowire' primitives (`stream.RequestReadeer`), execute the request, and return objects that understand what's involved in sending back a response, if it's a Unary call.
…es a stream.RequestReader and cleanup tests
Since this is a completely green path, we don't need to make stream.RequestReader an optional upgrade.
Co-authored-by: Abhinav Gupta <abg@uber.com>
Co-authored-by: Abhinav Gupta <abg@uber.com>
138ede4
to
68ba5cd
Compare
thriftrw's 'nowire' implementation (known as 'streaming' in the thriftrw
context) is an alternative wire-compatible implementation of the Thrift
protocol that bypasses the intermediate 'thriftrw.Wire' representation and
'streams' the protocol directly to the related objects.
This provides the mechanisms to handle 'Call's made via the 'nowire'
implementation instead of the existing 'Wire'-intermediary format. Doing so
involved creating a new type,
thriftNoWireHandler
, that implements both atransport.UnaryHandler
and atransport.OnewayHandler
.These call into a new interface,
NoWireHandler
(which will be implemented bygenerated code, for each procedure), that understands how to unpack the request
using thriftrw's 'nowire' primitives (
stream.RequestReadeer
), execute therequest, and return objects that understand what's involved in sending back a
response, if it's a Unary call.