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.3.1.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: thriftpy2-httpx-client-0.3.1.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for thriftpy2-httpx-client-0.3.1.tar.gz
Algorithm Hash digest
SHA256 56e8683a8e95ecfb7ea059b9a73a10f638f7f7f97d1f25990b9b0d2a2061aab7
MD5 76b2d58948f3c32d32dde1b19ba1eb53
BLAKE2b-256 36f1989c58ddf85e4a8f534e45c1333e1edcb33805746fa04b46e546c4edfd42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for thriftpy2_httpx_client-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 980c88013ceb367428fa9971cd1d4c06f3995ce9ea41b41720dcc3f7d010f945
MD5 d041847a88483b4148adc5837210d6a5
BLAKE2b-256 2c96c63b0df5a1d970f063b8a38bf75a58e84608d76bfe5d151166d1d231aeaf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page