-
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 perform outbound requests via thriftrw's "nowire" implementation #2088
encoding/thrift: Add mechanisms to perform outbound requests via thriftrw's "nowire" implementation #2088
Conversation
An alternative to creating a new Client interface and corresponding struct for implementing the "no-wire" representation would be to have the existing Since Go doesn't allow for multiple names of the same method defined in a struct, the names of the methods would likely have a separate verb. While generally this is probably fine, having the same struct implement two different 'verbages' to satisfy wire and no-wire ThriftRW compatibility feels really awkward. My preference here was to use the same verbage and create a completely independent client. |
2f25e2f
to
55d69a5
Compare
db3ee9c
to
aeef276
Compare
4e531d3
to
fbf7088
Compare
4ef59db
to
6940740
Compare
fbf7088
to
4ec75e3
Compare
6940740
to
3a44234
Compare
4ec75e3
to
ffab08c
Compare
3a44234
to
2db2c4d
Compare
Codecov Report
@@ Coverage Diff @@
## nowiredev #2088 +/- ##
=============================================
+ Coverage 87.56% 87.62% +0.05%
=============================================
Files 248 249 +1
Lines 13794 13933 +139
=============================================
+ Hits 12079 12209 +130
- Misses 1331 1335 +4
- Partials 384 389 +5
Continue to review full report at Codecov.
|
541cca5
to
6b9876d
Compare
bde05d3
to
102ab1e
Compare
6b9876d
to
72ec1ab
Compare
102ab1e
to
69776f9
Compare
if c.nwc != nil && c.nwc.Enabled() { | ||
err = c.nwc.Call(ctx, args, &result, opts...) | ||
if err != nil { | ||
return | ||
} | ||
} else { |
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 don't love this if-else but I don't see any other straightforward way to make this an opt-in flag so I can live with this.
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.
This is fine I think. Only other way would be to duplicate the last return and have something like this:
var result test.TestService_Call_Result
args := test.TestService_Call_Helper.Args(_Key)
if c.nwc != nil && c.nwc.Enabled() {
if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
return
}
success, err = test.TestService_Call_Helper.UnwrapResponse(&result)
return
}
var body wire.Value
body, err = c.c.Call(ctx, args, opts...)
if err != nil {
return
}
if err = result.FromWire(body); err != nil {
return
}
success, err = test.TestService_Call_Helper.UnwrapResponse(&result)
return
This improves the readability IMO but this is fine to have the else - up to you @witriew
nit: err can be inline
if c.nwc != nil && c.nwc.Enabled() { | ||
err = c.nwc.Call(ctx, args, &result, opts...) | ||
if err != nil { | ||
return | ||
} | ||
} else { |
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.
This is fine I think. Only other way would be to duplicate the last return and have something like this:
var result test.TestService_Call_Result
args := test.TestService_Call_Helper.Args(_Key)
if c.nwc != nil && c.nwc.Enabled() {
if err = c.nwc.Call(ctx, args, &result, opts...); err != nil {
return
}
success, err = test.TestService_Call_Helper.UnwrapResponse(&result)
return
}
var body wire.Value
body, err = c.c.Call(ctx, args, opts...)
if err != nil {
return
}
if err = result.FromWire(body); err != nil {
return
}
success, err = test.TestService_Call_Helper.UnwrapResponse(&result)
return
This improves the readability IMO but this is fine to have the else - up to you @witriew
nit: err can be inline
d3d4c41
to
ddc6103
Compare
72ec1ab
to
2ca90f6
Compare
294040e
to
a191e01
Compare
2ca90f6
to
e7c0ab5
Compare
a191e01
to
1f3d2b4
Compare
e7c0ab5
to
40fc262
Compare
…trw streaming protocol
…yStreamHandler" to support thriftrw streaming protocol
… protocol for outbound requests
… yarpc client code @smyth provided the initial logic for making oubounds thrift calls using the thriftrw 'no-wire' (read: streaming) implementation. Leverage this logic in the generated yarpc client code. This is done through generating a completely independent client and leveraging that code path iff the new no-wire client was generated and if it was enabled.
1f3d2b4
to
2e703cb
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 a no-wire compatible Client that can perform requests using
thriftrw's 'nowire' implementation. Much of this code is similar to the
existing Clients that use the 'wire' implementation of thriftrw, except that the
new no-wire Client provides an additional method
Enabled()
that returnswhether or not this client should be used, if set as an incoming option.
Additionally, the response's body is passed in to properly perform the
'Decode'ing of the protocol into the struct itself.