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

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.4.2.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

transmit-0.4.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: transmit-0.4.2.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.0 Windows/10

File hashes

Hashes for transmit-0.4.2.tar.gz
Algorithm Hash digest
SHA256 04b920cb67d62451b3453d82d55a6cf0b7e00cffabe8a80bd78914fb5ef69929
MD5 cfbf597a5320962590041386ef124d11
BLAKE2b-256 7e220345547c47c87c88bf6c09aa1b0c1d77508e5e5cd31929ee841db3830d0e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: transmit-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.0 Windows/10

File hashes

Hashes for transmit-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f76cfd45d864af5b1ece660152a88b001a6f9d0af2f4e9518400bc725d346d1
MD5 9b107122f53e68c7c3aa7243a5e3c059
BLAKE2b-256 5fcb3a8e5b7ef000fbc3533983178ec4aec787ae51b8d1ee4b87acec2eabf445

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page