# thrift-pool-client
**Repository Path**: mirrors_gspandy/thrift-pool-client
## Basic Information
- **Project Name**: thrift-pool-client
- **Description**: thrift-pool-client
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-09-24
- **Last Updated**: 2025-09-13
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# thrift-pool-client
thrift-pool-client
> * raw and type safe TServiceClient pool
> * Multi backend servers support
> * Backend servers replace on the fly
> * Backend route by hash or random
> * Failover and failback support
# Get Started
mvn dependency
```xml
com.github.phantomthief
thrift-pool-client
1.0.0
```
java code sample
```java
public class ThriftMain {
public static void main(String[] args) throws TException {
// customize pool config
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
// ... customize pool config here
// customize transport, while if you expect pooling the connection, you should use TFrameTransport.
Function transportProvider = new Function() {
@Override
public TTransport apply(ThriftServerInfo info) {
// TODO Auto-generated method stub
TSocket socket = new TSocket(info.getHost(), info.getPort());
return socket;
}
};
Function, List> addElementFunction =
new Function, List>() {
@Override
public List apply(List list) {
return Arrays.asList(//
ThriftServerInfo.of("192.168.1.44", 8080)//
// or you can return a dynamic result.
);
}
};
Supplier> list = Suppliers.compose(addElementFunction, new Supplier>(){
@Override
public List get() {
// TODO Auto-generated method stub
return Arrays.asList(//
ThriftServerInfo.of("192.168.1.44", 8080)//
// or you can return a dynamic result.
);
}});
// System.out.println("list1 "+list.get());
// System.out.println("list2 "+list.get());
ThriftClient thriftClient = new ThriftClientImpl( list,new DefaultThriftConnectionPoolImpl(poolConfig, transportProvider));
System.out.println("######start");
System.out.println(thriftClient.iface(ArithmeticService.Client.class).add(1,99));
System.out.println("######end");
}
}
```
# Special Thanks
perlmonk with his great team gives me a huge help. (https://github.com/PhantomThief/thrift-pool-client)