HTTPX Client for ThriftPy2
Project description
This package is provides an alternative HTTP client for ThriftPy2 which uses HTTPX instead of the builtin http.client and http.server libraries. This allows the developer to use more complex features like authentication, fine grained timeouts, and asyncio.
Examples:
Setup (Borrowed from ThriftPy2 Docs):
# pingpong.thrift
service PingPong {
string ping(),
}
import thriftpy2
from thriftpy2.http import make_server
pingpong_thrift = thriftpy2.load(
"pingpong.thrift",
module_name="pingpong_thrift",
)
class Dispatcher(object):
def ping(self):
return "pong"
server = make_server(
service=pingpong_thrift.PingPong,
handler=Dispatcher(),
host='127.0.0.1',
port=6000,
)
server.serve()
Async Usage:
from thriftpy2_httpx_client import make_aio_client
client = await make_aio_client(pingpong_thrift, url='http://localhost:6000')
print(await client.ping()) # prints 'pong'
Sync Usage:
from thriftpy2_httpx_client import make_sync_client
client = make_sync_client(pingpong_thrift, url='http://localhost:6000')
print(client.ping()) # prints 'pong'
Additional keyword arguments can be passed to the client to configure the internal httpx.AsyncClient() and httpx.Client() instances. For example, you can enable Kerberos authentication using httpx-gssapi:
from httpx_gssapi import HTTPSPNEGOAuth
from thriftpy2_httpx_client import make_aio_client
client = await make_aio_client(
pingpong_thrift,
url='http://localhost:6000',
auth=HTTPSPNEGOAuth(),
)
print(await client.ping()) # prints 'pong'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file thriftpy2-httpx-client-0.4.1.tar.gz
.
File metadata
- Download URL: thriftpy2-httpx-client-0.4.1.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2f4e12d4a1503d17d6f2b4be13d4d9f10c902f197276ed53cc754e428052a2d |
|
MD5 | 102e97f14ec5b23deee74b964bcd6fd0 |
|
BLAKE2b-256 | 5eb49b8c6a71bf49af5ae3af8f17f8cce9df800a1ea985b42c666bef17ce6619 |
File details
Details for the file thriftpy2_httpx_client-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: thriftpy2_httpx_client-0.4.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66c71c5a185ed6924b98b235be4f5f3c5d23bda7098e6d7861fed26fc56e0dca |
|
MD5 | 77611c7c3b86d10b2330641830944b1c |
|
BLAKE2b-256 | e134457c477312c6d7a444f2c639d6e8de566a988226727fcc5c178a2fd86b49 |