Thrift client pool for Takumi
Project description
Thrift client pool for Takumi.
Install
$ pip install takumi-client
Usage
This module relies on takumi-config for settings.
CLIENT_SETTINGS
service_name: required, service name defined in thrift file
thrift_file: required, existing thrift file path
pool_size: optional, connection pool size, default 30
timeout: optional, connection timeout, default 30s
check_time: optional, time interval for checking failed connections, default 10s
hosts: optional, a list of hosts: [(‘hostname’, port)]
hosts_class: optional, alternative class used to load hosts, default takumi_client.hosts.ListHosts
extra args: vary for different hosts classes
Example settings:
CLIENT_SETTINGS = {
'demo': {
'service_name': 'PingService',
'thrift_file': 'ping.thrift',
'hosts': [
('localhost', 1990),
('localhost', 8010),
('localhost', 1890)
]
}
}
To get a pool:
from takumi_client import clients
pool = clients['demo']
To invoke an api:
with pool.client_ctx() as c:
c.ping()
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
Built Distribution
Hashes for takumi_client-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31b48ffda8f742cf8f082a2576b3826e3159986b8a16a34cd09900610ac2061c |
|
MD5 | 5a8bc8ec9a23dd78aad5308a83cd9242 |
|
BLAKE2b-256 | 91471e16c10178b1ce0bb3ce3c1e6b28caff782f0b60697ad5802a89407ea7a0 |