forked from OpenStars/backendclients
/
transport.go
35 lines (28 loc) · 1.34 KB
/
transport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package transports
import (
"github.com/QuangVuong85/backendclients/go/treportstorageservice/thrift/gen-go/OpenStars/Common/TReportStorageService"
"log"
"github.com/OpenStars/thriftpoolv2"
"github.com/apache/thrift/lib/go/thrift"
)
var (
mTReportStorageServiceBinaryMapPool = thriftpoolv2.NewMapPool(1000, 3600, 3600,
thriftpoolv2.GetThriftClientCreatorFunc(func(c thrift.TClient) interface{} { return (TReportStorageService.NewTReportStorageServiceClient(c)) }),
thriftpoolv2.DefaultClose)
mTReportStorageServiceCommpactMapPool = thriftpoolv2.NewMapPool(1000, 3600, 3600,
thriftpoolv2.GetThriftClientCreatorFuncCompactProtocol(func(c thrift.TClient) interface{} { return (TReportStorageService.NewTReportStorageServiceClient(c)) }),
thriftpoolv2.DefaultClose)
)
func init() {
log.Println("init thrift TReportStorageService client ")
}
//GetTReportStorageServiceBinaryClient client by host:port
func GetTReportStorageServiceBinaryClient(aHost, aPort string) *thriftpoolv2.ThriftSocketClient {
client, _ := mTReportStorageServiceBinaryMapPool.Get(aHost, aPort).Get()
return client
}
//GetTReportStorageServiceCompactClient get compact client by host:port
func GetTReportStorageServiceCompactClient(aHost, aPort string) *thriftpoolv2.ThriftSocketClient {
client, _ := mTReportStorageServiceCommpactMapPool.Get(aHost, aPort).Get()
return client
}