Metadata-Version: 2.1
Name: thriftpy2-httpx-client
Version: 0.2
Summary: HTTPX Client for ThriftPy2
Home-page: https://github.com/aiudirog/ThriftPy2-HTTPX-Client
Author: Roger Aiudi
Author-email: aiudirog@gmail.com
License: MIT
Keywords: thrift,async,asyncio,httpx
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
License-File: LICENSE
Requires-Dist: thriftpy2 (>=0.4.11)
Requires-Dist: httpx (<0.19,>=0.16)
Requires-Dist: typing-extensions ; python_version < "3.8"

ThriftPy2 HTTPX Client
======================

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):**

.. code-block:: thrift

    # pingpong.thrift
    service PingPong {
        string ping(),
    }

.. code-block:: python

    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:**

.. code-block:: python

    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:**

.. code-block:: python

    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``:

.. code-block:: python

    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'


