semvec/pypi-packages huggingface dataset:
takumi-client 0.1.3
Thrift client pool for Takumi

takumi_client
=============

.. image:: https://travis-ci.org/elemepi/takumi-client.svg?branch=master
    :target: https://travis-ci.org/elemepi/takumi-client


Thrift client pool for Takumi.

Install
-------

.. code:: bash

    $ pip install takumi-client

Usage
-----

This module relies on `takumi-config <https://github.com/elemepi/takumi-config>`_ for settings.

- ``CLIENT_SETTINGS``

  * service: 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)]
  * extra args: vary for different hosts extensions


Example settings:

.. code:: python

    CLIENT_SETTINGS = {
        'demo': {
            'service': 'PingService',
            'thrift_file': 'ping.thrift',
            'hosts': [
                ('localhost', 1990),
                ('localhost', 8010),
                ('localhost', 1890)
            ]
        }
    }

To get a pool:

.. code:: python

    from takumi_client import clients

    pool = clients['demo']


To invoke an api:

.. code:: python

    with pool.client_ctx() as c:
        c.ping()