Hello,
I'm not really too familiar with thrift, but have used protobuf a
little, and think the general idea is quite similar. Anyhow, I've been
asked to update a thrift project. I found a simple idl definition
like:
struct Ainfo
{
1: required string url;
2: optional i32 a_rank;
3: optional byte generation;
4: optional i32 b_type;
5: optional string location;
6: optional i64 time;
}
service AinfoService
{
Ainfo getAinfo(
1: required string url
),
bool insertAinfo(
1: Ainfo details
),
Ainfo updateAinfo(
1: Ainfo details
),
}
Then it was simple enough to generate some python client similar to
the documentation at thrift.apache.org.
thrift --gen py ./api.thrift
import sys
import glob
sys.path.append('gen-py')
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from api import AinfoService
transport = TSocket.TSocket('thrift_server', 50055)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = AinfoService.Client(protocol)
transport.open()
client.getAinfo("http://www.example.com/testurl.htm")
At this point I'm just waiting for a return value, which doesn't seem
to happen. I can connect to the thrift service via telnet:
telnet thrift_server 50055
Trying thrift_server...
Connected to thrift_server.
Escape character is '^]'.
I'm using Apache Thrift v0.9.3 both for thrift --gen py ./api.thrift
and from pip2.7 . The project I'm using looks like they used Scrooge
and Thrift in their maven pom. I plan to move forward using that
project.
However, I thought the point of using thrift was to be language
agnostic, and so am trying to use python to verify this simple
definition.
Are scrooge thrift project(s) incompatible with this generator?
Any ideas on what I should approach next would be appreciated.