Skip to main content

Lib to connect to thrift services with pools

Project description

Simple connection pool for thrift. thrift_connector can be used both for native thrift client and thriftpy client with minor difference in usage.

Examples can be found in examples as well as the following sections.

Options

service

Defined thrift service. It should be the container class of apis for thriftpy (thriftpy.load(’…’).XXXService), and api module for thrift (XXX_sdk.xxx.xxxService)

host

Server host

port

Server port

[timeout]

Socket timeout, in seconds.

[name]

Connection pool name, for identity.

[raise_empty]

Whether to raise exception if pool is empty while trying to obtain a connection.

[max_conn]

Number of connections to manage in pool.

[connction_class]

Connection class implementation. Builtin classes are: ThriftClient for native thrift, ThriftPyClient and ThriftPyCyClient for thriftpy, the latter one utilize Cython for better performance.

[keepalive]

Seconds each connection is able to stay alive. If oen connection has lived longer than this period, it will be closed.

Usage

Examples for thriftpy is:

import thriftpy
from thrift_connector import ClientPool, ThriftPyCyClient

service = thriftpy.load("pingpong_app/pingpong.thrift")
pool = ClientPool(
    service.PingService,
    'localhost',
    8880,
    connction_class=ThriftPyCyClient
    )

print "Sending Ping..."
print "Receive:", pool.ping()
print "Winning the match..."
print "Receive:", pool.win()

Examples for thrift is:

# -*- coding: utf-8 -*-

from pingpong_app.pingpong_sdk.pingpong import PingService
from thrift_connector import ClientPool, ThriftClient

pool = ClientPool(
    PingService,
    'localhost',
    8880,
    connction_class=ThriftClient
    )

print "Sending Ping..."
print "Receive:", pool.ping()
print "Winning the match..."
print "Receive:", pool.win()

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

thrift_connector-0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

thrift_connector-0.1-py2-none-any.whl (3.8 kB view details)

Uploaded Python 2

File details

Details for the file thrift_connector-0.1.tar.gz.

File metadata

File hashes

Hashes for thrift_connector-0.1.tar.gz
Algorithm Hash digest
SHA256 79d053aa63b50aac2c6b032e5e1324df2fa963be761c466464435b3b00d17a4c
MD5 39749854a808710a9f0216115e109078
BLAKE2b-256 c0d67e8cd1e55eb9001b98b1aa960f30474eb24ba295eb6d829c9be7885c72ce

See more details on using hashes here.

File details

Details for the file thrift_connector-0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for thrift_connector-0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 b793d2dc9e6ccf615c95c7957b5b03bc2fff34a2f0f132124b0c2ce87611a8f5
MD5 01685c2e51af297e86109d56b16dce92
BLAKE2b-256 0adb6a58c345bc00d80254d31b807d487f3566dacee955be32bf95f99337970a

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