Thriftpy instruments for passing metadata
Project description
Thriftpy instruments for passing metadata bidirectional.
Example
# Server
class Ctx(object):
pass
ctx = Ctx()
ctx.response_meta = {'server': 'test'}
class Handler(object):
def say_hello(name):
assert ctx.meta == {'hello': 'test', 'client_name': 'test_client'}
return Response('Hello ' + name, meta={'api': 'say_hello'})
processor = Processor(ctx, service, Handler())
# Client
client = Client(service, proto, meta={'client_name': 'test_client'})
res = client.call('say_hello', 'world', meta={'hello': 'test'})
assert res.meta == {'api': 'say_hello', 'server': 'test'}
assert res.value == 'Hello world'
Data frame change
Request data frame:
before: message_begin args message_end after: meta_begin meta meta_end message_begin args message_end
Response data frame:
before: message_begin result message_end after: meta_begin meta meta_end message_begin result message_end
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.2.2.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for takumi_thrift-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db973e5e19bc47fdcdd1c8c7771726c603c2dac214b51f54bb0f9fa693f0adae |
|
MD5 | 64f13fad4abf2c248c886c404724d614 |
|
BLAKE2b-256 | 644e80e74a0b7f02bacdf9431e624771bb02090e5dcce6745f747e30e496c0a7 |