Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thriftpy2-httpx-client-0.4.1.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

thriftpy2_httpx_client-0.4.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file thriftpy2-httpx-client-0.4.1.tar.gz.

File metadata

File hashes

Hashes for thriftpy2-httpx-client-0.4.1.tar.gz
Algorithm Hash digest
SHA256 e2f4e12d4a1503d17d6f2b4be13d4d9f10c902f197276ed53cc754e428052a2d
MD5 102e97f14ec5b23deee74b964bcd6fd0
BLAKE2b-256 5eb49b8c6a71bf49af5ae3af8f17f8cce9df800a1ea985b42c666bef17ce6619

See more details on using hashes here.

File details

Details for the file thriftpy2_httpx_client-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for thriftpy2_httpx_client-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 66c71c5a185ed6924b98b235be4f5f3c5d23bda7098e6d7861fed26fc56e0dca
MD5 77611c7c3b86d10b2330641830944b1c
BLAKE2b-256 e134457c477312c6d7a444f2c639d6e8de566a988226727fcc5c178a2fd86b49

See more details on using hashes here.

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