Skip to main content

Transmit Server & Client use thrift

Project description

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

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

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

Advanced Usage

  1. debug mode

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

# debug server
> python test_server.py --debug 1
# debug client
with Client("127.0.0.1",18100,debug=True) as c:
    ...
  1. server cli setting
> python test_server.py --host="127.0.0.1" --port=3000 --workers=3 --type=<process|thread> --debug=1
  1. docker health check
python -m transmit.health_check

Refs

Thrift thrift几种server模式的比较

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

transmit-0.5.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

transmit-0.5.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file transmit-0.5.0.tar.gz.

File metadata

  • Download URL: transmit-0.5.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for transmit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a95c8112bf56a196007dfde24b18ecaa20ef9a99cb152421a4feb6095f1b7bc0
MD5 6e38e6eac5202598ff50b74d6dbb3ab9
BLAKE2b-256 e0148521ee1fa77b568e8c43b02554b1dbe31d9431fb25cd791686f18f1ff840

See more details on using hashes here.

File details

Details for the file transmit-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: transmit-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for transmit-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d96ff35572ce85fbce0084751a9a59ce2b3875f4ee754ba0c1241582114bffc4
MD5 74dd7262e4b4060645b1fd8c65a23038
BLAKE2b-256 c5d6e30865d2396bfa91513349f65ef51e2212c6df251ee04d556bcedd4b68a3

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