THRIFT-4612: Add THeaderTransportFactory to go library
Client: go
This was supposed to be in 4d46c11, but was forgotten.
Closes #1832.
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 @@
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
+}