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.0.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for takumi_thrift-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2de6f22ee5693919c04650f5c91318ea759b65015caf61110bb8aa1238ffa942 |
|
MD5 | 2203f97cc6f29a366bf5f174579376ac |
|
BLAKE2b-256 | 37cdaafdf552cfaec8e2888929fdda571357265294b7af93ec7067a12c43c606 |