1 Star 0 Fork 1

Samlily-Xie/RPC-Turbo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
thriftclient.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
xiaozhang 提交于 2019-06-17 16:00 +08:00 . upgrade thrift to 0.12
/*
* Copyright © 2017 Xiao Zhang <zzxx513@gmail.com>.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file.
*/
package turbo
import (
"github.com/apache/thrift/lib/go/thrift"
)
type thriftClient struct {
thriftService map[string]interface{}
transport thrift.TTransport
factory thrift.TProtocolFactory
}
func (t *thriftClient) init(addr string, clientCreator thriftClientCreator) {
if t.thriftService != nil {
return
}
log.Debugf("connecting thrift addr: %s", addr)
t.connect(addr)
t.thriftService = clientCreator(t.transport, t.factory)
}
func (t *thriftClient) connect(hostPort string) {
tSocket, err := thrift.NewTSocket(hostPort)
logPanicIf(err)
t.transport, err = thrift.NewTTransportFactory().GetTransport(tSocket)
logPanicIf(err)
err = t.transport.Open()
logPanicIf(err)
t.factory = thrift.NewTBinaryProtocolFactoryDefault()
}
func (t *thriftClient) close() error {
if t.transport == nil {
return nil
}
return t.transport.Close()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/samlily-xie/RPC-Turbo.git
git@gitee.com:samlily-xie/RPC-Turbo.git
samlily-xie
RPC-Turbo
RPC-Turbo
master

搜索帮助