thriftpy2-httpx-client


Namethriftpy2-httpx-client JSON
Version 0.4 PyPI version JSON
download
home_pagehttps://github.com/aiudirog/ThriftPy2-HTTPX-Client
SummaryHTTPX Client for ThriftPy2
upload_time2023-12-21 04:46:33
maintainer
docs_urlNone
authorRoger Aiudi
requires_python>=3.7
licenseMIT
keywords thrift async asyncio httpx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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'

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aiudirog/ThriftPy2-HTTPX-Client",
    "name": "thriftpy2-httpx-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "thrift,async,asyncio,httpx",
    "author": "Roger Aiudi",
    "author_email": "aiudirog@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8a/f4/adaf90ac114b877d3e6bc1c7f6e0d609307f50f5240956123c831c4468a4/thriftpy2-httpx-client-0.4.tar.gz",
    "platform": null,
    "description": "ThriftPy2 HTTPX Client\n======================\n\nThis package is provides an alternative HTTP client for ThriftPy2 which\nuses HTTPX instead of the builtin ``http.client`` and ``http.server``\nlibraries. This allows the developer to use more complex features like\nauthentication, fine grained timeouts, and asyncio.\n\nExamples:\n---------\n\n**Setup (Borrowed from ThriftPy2 Docs):**\n\n.. code-block:: thrift\n\n    # pingpong.thrift\n    service PingPong {\n        string ping(),\n    }\n\n.. code-block:: python\n\n    import thriftpy2\n    from thriftpy2.http import make_server\n\n    pingpong_thrift = thriftpy2.load(\n        \"pingpong.thrift\",\n        module_name=\"pingpong_thrift\",\n    )\n\n    class Dispatcher(object):\n        def ping(self):\n            return \"pong\"\n\n    server = make_server(\n        service=pingpong_thrift.PingPong,\n        handler=Dispatcher(),\n        host='127.0.0.1',\n        port=6000,\n    )\n    server.serve()\n\n\n**Async Usage:**\n\n.. code-block:: python\n\n    from thriftpy2_httpx_client import make_aio_client\n\n    client = await make_aio_client(pingpong_thrift, url='http://localhost:6000')\n    print(await client.ping())  # prints 'pong'\n\n\n**Sync Usage:**\n\n.. code-block:: python\n\n    from thriftpy2_httpx_client import make_sync_client\n\n    client = make_sync_client(pingpong_thrift, url='http://localhost:6000')\n    print(client.ping())  # prints 'pong'\n\n\nAdditional keyword arguments can be passed to the client to configure\nthe internal ``httpx.AsyncClient()`` and ``httpx.Client()`` instances. For\nexample, you can enable Kerberos authentication using ``httpx-gssapi``:\n\n.. code-block:: python\n\n    from httpx_gssapi import HTTPSPNEGOAuth\n    from thriftpy2_httpx_client import make_aio_client\n\n    client = await make_aio_client(\n        pingpong_thrift,\n        url='http://localhost:6000',\n        auth=HTTPSPNEGOAuth(),\n    )\n    print(await client.ping())  # prints 'pong'\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "HTTPX Client for ThriftPy2",
    "version": "0.4",
    "project_urls": {
        "Homepage": "https://github.com/aiudirog/ThriftPy2-HTTPX-Client"
    },
    "split_keywords": [
        "thrift",
        "async",
        "asyncio",
        "httpx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52f2353bab694ebc0a7c3bc3000324d82b8c6b6db10b4251e65e688e1d683921",
                "md5": "68e4552330c69df90fb7dba5c2bd4dbc",
                "sha256": "3be38e32c668af1f3123aff297bd3f7fb57709a14a60f66e3405312cff6aba43"
            },
            "downloads": -1,
            "filename": "thriftpy2_httpx_client-0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "68e4552330c69df90fb7dba5c2bd4dbc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9724,
            "upload_time": "2023-12-21T04:46:32",
            "upload_time_iso_8601": "2023-12-21T04:46:32.247577Z",
            "url": "https://files.pythonhosted.org/packages/52/f2/353bab694ebc0a7c3bc3000324d82b8c6b6db10b4251e65e688e1d683921/thriftpy2_httpx_client-0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8af4adaf90ac114b877d3e6bc1c7f6e0d609307f50f5240956123c831c4468a4",
                "md5": "e5f2772436d47f7ffe8cbccbf7e5c594",
                "sha256": "bb74528586e23b0a85e5bb152b229f9237b781811416294ba552fead7c6267f0"
            },
            "downloads": -1,
            "filename": "thriftpy2-httpx-client-0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e5f2772436d47f7ffe8cbccbf7e5c594",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 28570,
            "upload_time": "2023-12-21T04:46:33",
            "upload_time_iso_8601": "2023-12-21T04:46:33.595258Z",
            "url": "https://files.pythonhosted.org/packages/8a/f4/adaf90ac114b877d3e6bc1c7f6e0d609307f50f5240956123c831c4468a4/thriftpy2-httpx-client-0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-21 04:46:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aiudirog",
    "github_project": "ThriftPy2-HTTPX-Client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "thriftpy2-httpx-client"
}
        
Elapsed time: 0.22334s