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.0.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for takumi_thrift-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 456a0c457550cac1c48da9d8c75765dc438df156d7bff9d42159c7223658fa37 |
|
MD5 | 539772b67ae4abf4e988167565215f24 |
|
BLAKE2b-256 | 84ec5a3adbad62e52acd5be1c7d18a1504eab941182ee4306269f7bd097ae6bc |