vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
936 stars 92 forks source link

How to send metadata from client? #59

Closed zeyadsalloum closed 5 years ago

zeyadsalloum commented 5 years ago

is there an example of how the client would send metadata?

nickpro commented 5 years ago

hey. check snippet below, hope it'll help.

stub = UserHandlerStub(channel)
request_metadata = {'auth_token': 'some-strongly-hashed-token'}
await stub.UpdateProfile(UpdateProfileRequest(username='benaffleck'), metadata=request_metadata)
vmagamedov commented 5 years ago

Currently there is a lack of examples and documentation about sending and receiving metadata. Going to fix this soon. Here is what we have for now: UnaryUnaryMethod.__call__

@nickpro I think that you have a typo in your example :)

await stub.UpdateProfile(UpdateProfileRequest(username='benaffleck'),
                         metadata=request_metadata)
nickpro commented 5 years ago

@vmagamedov right you, fixed my previous reply, thanks!

vmagamedov commented 5 years ago

@zeyadsalloum documented metadata usage here: https://grpclib.readthedocs.io/en/latest/metadata.html

Is it Ok to close this issue?

zeyadsalloum commented 5 years ago

yup. Thanks for the updating the docs