Thriftpy instruments for passing metadata
Project description
Thriftpy instruments for passing metadata bidirectional.
Example
from takumi_thrift import Processor, Response
ping = load('ping.thrift')
class Handler(object):
def ping_api(self, **kwargs):
return Response('pong', meta={'server_id': 'test_server'})
# server
from thriftpy.transport import TServerSocket
from thriftpy.server import TSimpleServer
sock = TServerSocket(host='localhost', port=1990)
processor = Processor(ping.PingService, Handler())
server = TSimpleServer(processor, sock)
server.serve()
# client
from thriftpy.transport import TBufferedTransportFactory, TSocket
from thriftpy.protocol import TBinaryProtocolFactory
from takumi_thrift import Client
sock = TScoket(host='localhost', port=1990)
trans = TBufferedTransportFactory().get_transport(sock)
proto = TBinaryProtocolFactory().get_protocol(trans)
trans.open()
client = Client(ping.PingService, proto)
client.ping_api(meta={'hello': 'world', 'client_name': 'test_client'})
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
takumi_thrift-0.1.2.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for takumi_thrift-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc26129f8872889f04a99b76cf3df9b2a1144a9682a1aae38c8a102137b4d2a4 |
|
MD5 | d580a2fac5540a8a807c539c364f3eae |
|
BLAKE2b-256 | c360576f26b53aea17f5e09ecbbf397fa5a83b6ed3a071a708ffd67d590f7b33 |