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.2.4.tar.gz (25.3 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.2.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: thriftpy2-httpx-client-0.2.4.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for thriftpy2-httpx-client-0.2.4.tar.gz
Algorithm Hash digest
SHA256 865363b094013e1f62e16da77f0547dc2263d861829ac01b3f6f64bdd0ca1174
MD5 831240a49b1c51297c1a7855316e690a
BLAKE2b-256 aff642fd61510a20f2a3b48765b52ce0fe65c312e9cea12bf71acedb9d6cda61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thriftpy2_httpx_client-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for thriftpy2_httpx_client-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bd1c42d3bc680550e1f8012477323b12642f00b189871eb2e72b02c12104c860
MD5 58cc505719ac278b28c4eb59a5265c30
BLAKE2b-256 cd5ca342de49b62e7ed4571628f22636303b7d693837f98bc00ffeb2841cc100

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