當前位置: 首頁>>代碼示例>>Golang>>正文


Golang TTransport.IsOpen方法代碼示例

本文整理匯總了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
}
開發者ID:lasithasenanayake,項目名稱:v6engine-deps,代碼行數:33,代碼來源:hiveclient.go

示例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)}
}
開發者ID:mvpmvh,項目名稱:DE2,代碼行數:23,代碼來源:user.go


注:本文中的git/apache/org/thrift/git/lib/go/thrift.TTransport.IsOpen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。