Coder Social home page Coder Social logo

thrift_connector's Introduction

Thrift Connector

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 utilizes 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()

thrift_connector's People

Contributors

ritksm avatar wooparadog avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.