You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dc...@apache.org on 2019/07/24 15:42:16 UTC
[thrift] branch master updated: THRIFT-4612: Add
THeaderTransportFactory to go library
This is an automated email from the ASF dual-hosted git repository.
dcelasun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new ebb6b2e THRIFT-4612: Add THeaderTransportFactory to go library
ebb6b2e is described below
commit ebb6b2ed68a4e0a986ce3a7797fb4ae054aa23ac
Author: Yuxuan 'fishy' Wang <yu...@reddit.com>
AuthorDate: Wed Jul 24 08:42:06 2019 -0700
THRIFT-4612: Add THeaderTransportFactory to go library
Client: go
This was supposed to be in 4d46c11, but was forgotten.
Closes #1832.
---
lib/go/thrift/header_transport.go | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/lib/go/thrift/header_transport.go b/lib/go/thrift/header_transport.go
index 3e68460..4302635 100644
--- a/lib/go/thrift/header_transport.go
+++ b/lib/go/thrift/header_transport.go
@@ -690,3 +690,29 @@ func (t *THeaderTransport) isFramed() bool {
return true
}
}
+
+// THeaderTransportFactory is a TTransportFactory implementation to create
+// THeaderTransport.
+type THeaderTransportFactory struct {
+ // The underlying factory, could be nil.
+ Factory TTransportFactory
+}
+
+// NewTHeaderTransportFactory creates a new *THeaderTransportFactory.
+func NewTHeaderTransportFactory(factory TTransportFactory) TTransportFactory {
+ return &THeaderTransportFactory{
+ Factory: factory,
+ }
+}
+
+// GetTransport implements TTransportFactory.
+func (f *THeaderTransportFactory) GetTransport(trans TTransport) (TTransport, error) {
+ if f.Factory != nil {
+ t, err := f.Factory.GetTransport(trans)
+ if err != nil {
+ return nil, err
+ }
+ return NewTHeaderTransport(t), nil
+ }
+ return NewTHeaderTransport(trans), nil
+}