transmit


Nametransmit JSON
Version 0.4.2 PyPI version JSON
download
home_pagehttps://github.com/hbh112233abc/py-transmit
SummaryTransmit Server & Client use thrift
upload_time2024-11-18 09:34:29
maintainerNone
docs_urlNone
authorhbh112233abc
requires_python<4.0,>=3.7
licenseMIT
keywords thrift transmit json
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Transmit Server & Client

## Install

```
pip install transmit
```

## Usage

### Server

```
from transmit.server import Server

class TestServer(Server):
    def __init__(self,port=18100):
        super().__init__(port)

    def test_function(self,msg):
        print('Testing:',msg)
        return {"say":"Happy everyday!!!"}

if __name__ == '__main__':
    ts = TestServer()
    ts.run()

```

> Result

```shell
START SERVER 0.0.0.0:18100

```

#### Success Response

```
{
    "code":1,
    "msg":"success",
    "data":"handle result data. AnyType"
}
```

#### Error Response

```
{
    "code":0,
    "msg":"error message",
    "data":null
}
```

### Client

```
from transmit.client import Client

with Client("127.0.0.1",18100) as c:
    result = c.test_function({"msg":"hello world"})
    print(type(result))
    print(result)

```

> Result

```shell
> <class 'dict'>
> {'say': 'Happy everyday!!!'}
```

### Advanced Usage

1. debug mode

debug mode will print and log all request and response data.

```shell
# debug server
> python test_server.py --debug 1
```

```python
# debug client
with Client("127.0.0.1",18100,debug=True) as c:
    ...
```

2. server cli setting

```shell
> python test_server.py --host="127.0.0.1" --port=3000 --workers=3 --type=<process|thread> --debug=1
```

### Refs

[Thrift](https://thrift.apache.org/)
[thrift几种server模式的比较](https://blog.csdn.net/hzllblzjily/article/details/50645114)

```

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hbh112233abc/py-transmit",
    "name": "transmit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.7",
    "maintainer_email": null,
    "keywords": "thrift, transmit, json",
    "author": "hbh112233abc",
    "author_email": "hbh112233abc@163.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/22/0345547c47c87c88bf6c09aa1b0c1d77508e5e5cd31929ee841db3830d0e/transmit-0.4.2.tar.gz",
    "platform": null,
    "description": "# Transmit Server & Client\n\n## Install\n\n```\npip install transmit\n```\n\n## Usage\n\n### Server\n\n```\nfrom transmit.server import Server\n\nclass TestServer(Server):\n    def __init__(self,port=18100):\n        super().__init__(port)\n\n    def test_function(self,msg):\n        print('Testing:',msg)\n        return {\"say\":\"Happy everyday!!!\"}\n\nif __name__ == '__main__':\n    ts = TestServer()\n    ts.run()\n\n```\n\n> Result\n\n```shell\nSTART SERVER 0.0.0.0:18100\n\n```\n\n#### Success Response\n\n```\n{\n    \"code\":1,\n    \"msg\":\"success\",\n    \"data\":\"handle result data. AnyType\"\n}\n```\n\n#### Error Response\n\n```\n{\n    \"code\":0,\n    \"msg\":\"error message\",\n    \"data\":null\n}\n```\n\n### Client\n\n```\nfrom transmit.client import Client\n\nwith Client(\"127.0.0.1\",18100) as c:\n    result = c.test_function({\"msg\":\"hello world\"})\n    print(type(result))\n    print(result)\n\n```\n\n> Result\n\n```shell\n> <class 'dict'>\n> {'say': 'Happy everyday!!!'}\n```\n\n### Advanced Usage\n\n1. debug mode\n\ndebug mode will print and log all request and response data.\n\n```shell\n# debug server\n> python test_server.py --debug 1\n```\n\n```python\n# debug client\nwith Client(\"127.0.0.1\",18100,debug=True) as c:\n    ...\n```\n\n2. server cli setting\n\n```shell\n> python test_server.py --host=\"127.0.0.1\" --port=3000 --workers=3 --type=<process|thread> --debug=1\n```\n\n### Refs\n\n[Thrift](https://thrift.apache.org/)\n[thrift\u51e0\u79cdserver\u6a21\u5f0f\u7684\u6bd4\u8f83](https://blog.csdn.net/hzllblzjily/article/details/50645114)\n\n```\n\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Transmit Server & Client use thrift",
    "version": "0.4.2",
    "project_urls": {
        "Documentation": "https://github.com/hbh112233abc/py-transmit",
        "Homepage": "https://github.com/hbh112233abc/py-transmit",
        "Repository": "https://github.com/hbh112233abc/py-transmit"
    },
    "split_keywords": [
        "thrift",
        " transmit",
        " json"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5fcb3a8e5b7ef000fbc3533983178ec4aec787ae51b8d1ee4b87acec2eabf445",
                "md5": "9b107122f53e68c7c3aa7243a5e3c059",
                "sha256": "0f76cfd45d864af5b1ece660152a88b001a6f9d0af2f4e9518400bc725d346d1"
            },
            "downloads": -1,
            "filename": "transmit-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9b107122f53e68c7c3aa7243a5e3c059",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 9803,
            "upload_time": "2024-11-18T09:34:27",
            "upload_time_iso_8601": "2024-11-18T09:34:27.899773Z",
            "url": "https://files.pythonhosted.org/packages/5f/cb/3a8e5b7ef000fbc3533983178ec4aec787ae51b8d1ee4b87acec2eabf445/transmit-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e220345547c47c87c88bf6c09aa1b0c1d77508e5e5cd31929ee841db3830d0e",
                "md5": "cfbf597a5320962590041386ef124d11",
                "sha256": "04b920cb67d62451b3453d82d55a6cf0b7e00cffabe8a80bd78914fb5ef69929"
            },
            "downloads": -1,
            "filename": "transmit-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cfbf597a5320962590041386ef124d11",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 7465,
            "upload_time": "2024-11-18T09:34:29",
            "upload_time_iso_8601": "2024-11-18T09:34:29.633203Z",
            "url": "https://files.pythonhosted.org/packages/7e/22/0345547c47c87c88bf6c09aa1b0c1d77508e5e5cd31929ee841db3830d0e/transmit-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 09:34:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hbh112233abc",
    "github_project": "py-transmit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "transmit"
}
        
Elapsed time: 0.49086s