分类: LINUX
2010-09-25 15:40:48
enum ResultCode
{
OK,
TRY_LATER
}
struct LogEntry
{
1: string category,
2: string message
}
service scribe extends fb303.FacebookService
{
ResultCode Log(1: list messages);
}
from scribe import scribe
from thrift.transport import TTransport, TSocket
from thrift.protocol import TBinaryProtocol
category='test'
message='hello world'
log_entry = scribe.LogEntry(category, message)
# depending on thrift version
# log_entry = scribe.LogEntry(dict(category=category, message=message))
socket = TSocket.TSocket(host='localhost', port=1456)
transport = TTransport.TFramedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(trans=transport, strictRead=False, strictWrite=False)
client = scribe.Client(iprot=protocol, oprot=protocol)
transport.open()
result = client.Log(messages=[log_entry])
transport.close()