本文整理匯總了Golang中git/apache/org/thrift/git/lib/go/thrift.TTransport.IsOpen方法的典型用法代碼示例。如果您正苦於以下問題:Golang TTransport.IsOpen方法的具體用法?Golang TTransport.IsOpen怎麽用?Golang TTransport.IsOpen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類git/apache/org/thrift/git/lib/go/thrift.TTransport
的用法示例。
在下文中一共展示了TTransport.IsOpen方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Open
// opens a hive connection
func (conn *HiveConnection) Open() error {
log.Println("creating new hive connection ")
var transport thrift.TTransport
var err error
transport, err = thrift.NewTSocket(conn.Server)
if err != nil {
return err
}
if transport == nil {
return errors.New("No TSocket connection?")
}
transport.Open()
// NewTBinaryProtocolTransport(t TTransport) *TBinaryProtocol {
protocolfac := thrift.NewTBinaryProtocolFactoryDefault()
//NewThriftHiveClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol)
conn.Client = thrifthive.NewThriftHiveClientFactory(transport, protocolfac)
log.Printf("is open? %v", transport.IsOpen())
name, err := conn.Client.GetName()
log.Printf("in conn.Open, how is client? %v %v", name, err)
if conn.Client == nil {
log.Println("ERROR, no client")
return errors.New("no client")
}
return nil
}
示例2: NewUserService
func NewUserService() *services.UserService {
var transport thrift.TTransport
var err error
addr := beego.AppConfig.String("socketAddress")
if transport, err = thrift.NewTSocket(addr); err != nil {
panic("Unable to initialize socket!")
}
transportFactory := thrift.NewTTransportFactory()
protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
transport = transportFactory.GetTransport(transport)
if !transport.IsOpen() {
if err = transport.Open(); err != nil {
panic("Unable to open socket!")
}
}
return &services.UserService{user.NewUserServicerClientFactory(transport, protocolFactory)}
}