Thrift Pool

This library provides a simple way implement bb8 and/or r2d2 Connection Pools for any TThriftClient

```rust use thrift::protocol::{TCompactInputProtocol, TCompactOutputProtocol, TInputProtocol, TOutputProtocol}; use thrift::transport::{ ReadHalf, TFramedReadTransport, TFramedWriteTransport, TTcpChannel, WriteHalf, }; use thrift_pool::{MakeThriftConnectionFromAddrs, ThriftConnectionManager, ThriftConnection, FromProtocol}; use r2d2::Pool;

struct MyThriftClient { iprot: Ip, oprot: Op, }

impl FromProtocol for MyThriftClient { type InputProtocol = Ip;

type OutputProtocol = Op;

fn from_protocol(
    input_protocol: Self::InputProtocol,
    output_protocol: Self::OutputProtocol,
) -> Self {
    MyThriftClient {
        i_prot: input_protocol,
        o_prot: output_protocol,
    }
}

}

impl ThriftConnection for MyThriftClient { type Error = thrift::Error; fn isvalid(&mut self) -> Result<(), Self::Error> { Ok(()) } fn hasbroken(&mut self) -> bool { false } }

type Client = MyThriftClient< TCompactInputProtocol>>, TCompactOutputProtocol>>,

;

let manager = ThriftConnectionManager::new( MakeThriftConnectionFromAddrs::::new("localhost:9090") ); let pool = Pool::builder().build(manager)?; let mut client = pool.get()?; ```

Documentation

Examples