Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
witriew committed Aug 30, 2021
1 parent 039ecc8 commit 40fc262
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions encoding/thrift/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ func Protocol(p protocol.Protocol) Option {
}

// NoWire is an option that specifies to *not* use the thriftrw.Wire
// intermediary format. Note that if this is enabled, and a
// 'protocol.Protocol' is provided (e.g., via thrift.Protocol)m that provided
// protocol must be able to satisfy the 'stream.Protocol' interface.
// intermediary format. Note that if this is enabled, and a
// 'protocol.Protocol' is provided (e.g., via thrift.Protocol) that provided
// protocol must be able to satisfy the 'stream.RequestReader' interface.
// Will become the default option.
func NoWire(enable bool) Option {
return noWireOption{Enable: enable}
}
Expand Down
8 changes: 5 additions & 3 deletions encoding/thrift/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure {
proto = rc.Protocol
}

// Only if we're trying to use the 'NoWire' implementation do we check if the
// config's `Protocol` provides the streaming ones needed.
var streamReqReader stream.RequestReader = binary.Default
if rc.Protocol != nil && rc.NoWire {
if rc.NoWire && rc.Protocol != nil {
if sp, ok := rc.Protocol.(stream.RequestReader); ok {
streamReqReader = sp
}
Expand All @@ -115,7 +117,7 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure {
case transport.Unary:
if rc.NoWire {
spec = transport.NewUnaryHandlerSpec(thriftNoWireHandler{
NoWireHandler: method.HandlerSpec.NoWire,
Handler: method.HandlerSpec.NoWire,
RequestReader: streamReqReader,
})
} else {
Expand All @@ -128,7 +130,7 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure {
case transport.Oneway:
if rc.NoWire {
spec = transport.NewOnewayHandlerSpec(thriftNoWireHandler{
NoWireHandler: method.HandlerSpec.NoWire,
Handler: method.HandlerSpec.NoWire,
RequestReader: streamReqReader,
})
} else {
Expand Down

0 comments on commit 40fc262

Please sign in to comment.