Thrift Client. Golang

Пример создания клиента для Thrift сервера. Последняя строка это вызов метода.

func main() {
	transportFactory := thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), nil)
	protocolFactoryBinary := thrift.NewTBinaryProtocolFactoryConf(nil)
 
	// protocolFactoryCompact := thrift.NewTCompactProtocolFactoryConf(nil)
	protocolFactoryDebug := thrift.NewTDebugProtocolFactoryWithLogger(protocolFactoryBinary, "", thrift.StdLogger(log.Default()))
 
	transport := thrift.NewTSocketConf(net.JoinHostPort(HOST, PORT), nil)
 
	useTransport, err := transportFactory.GetTransport(transport)
	if err != nil {
		log.Fatal(err)
	}
 
	client := trino.NewTrinoThriftServiceClientFactory(useTransport, protocolFactoryDebug)
	if err := transport.Open(); err != nil {
		fmt.Fprintln(os.Stderr, "Error opening socket to "+HOST+":"+PORT, " ", err)
		os.Exit(1)
	}
	defer transport.Close()
 
	fmt.Println(client.TrinoListSchemaNames(context.Background()))
}