Skip to main content

Thriftpy instruments for passing metadata

Project description

https://travis-ci.org/elemepi/takumi-thrift.svg?branch=master

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)

Uploaded Source

Built Distribution

takumi_thrift-0.1.2-py2.py3-none-any.whl (6.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page