Struct thrift_pool::MakeThriftConnectionFromAddrs [−][src]
pub struct MakeThriftConnectionFromAddrs<T, S> { /* fields omitted */ }Expand description
A MakeThriftConnection that attempts to create new connections
from a ToSocketAddrs and a FromProtocol
The connection is accordance with the thrift rust tutorial:
- Open a
TTcpChannel - Split it
- Create
TReadTransportandTWriteTransport - Create
TInputProtocolandTOutputProtocol - Create a client with
i_protando_prot
For that to happen, T needs to be able
to create the Read/Write Transports
and Input/Output Protocols from
the ReadHalf and WriteHalf of the TTcpChannel.
Those contraints should be fairly easily satisfied
by implementing the relevant traits in the library
use thrift_pool::{MakeThriftConnectionFromAddrs, FromProtocol};
use thrift::{
protocol::{TCompactInputProtocol, TCompactOutputProtocol, TInputProtocol, TOutputProtocol},
transport::{
ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel, TReadTransport,
TTcpChannel, TWriteTransport, WriteHalf,
},
};
// A typical generated client looks like this
struct MyThriftClient<Ip: TInputProtocol, Op: TOutputProtocol> {
i_prot: Ip,
o_prot: Op,
}
impl<Ip: TInputProtocol, Op: TOutputProtocol> FromProtocol for MyThriftClient<Ip, Op> {
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,
}
}
}
type Client = MyThriftClient<
TCompactInputProtocol<TFramedReadTransport<ReadHalf<TTcpChannel>>>,
TCompactOutputProtocol<TFramedWriteTransport<WriteHalf<TTcpChannel>>>,
>;
// The Protocols/Transports used in this client implement the necessary traits so we can do this
let manager =
MakeThriftConnectionFromAddrs::<Client, _>::new("localhost:9090").into_connection_manager();
Implementations
impl<S: ToSocketAddrs + Clone, Rt: FromRead<Read = ReadHalf<TTcpChannel>>, Ip: FromReadTransport<ReadTransport = Rt>, Wt: FromWrite<Write = WriteHalf<TTcpChannel>>, Op: FromWriteTransport<WriteTransport = Wt>, T: FromProtocol<InputProtocol = Ip, OutputProtocol = Op>> MakeThriftConnectionFromAddrs<T, S>
impl<S: ToSocketAddrs + Clone, Rt: FromRead<Read = ReadHalf<TTcpChannel>>, Ip: FromReadTransport<ReadTransport = Rt>, Wt: FromWrite<Write = WriteHalf<TTcpChannel>>, Op: FromWriteTransport<WriteTransport = Wt>, T: FromProtocol<InputProtocol = Ip, OutputProtocol = Op>> MakeThriftConnectionFromAddrs<T, S>
Trait Implementations
impl<S: ToSocketAddrs + Clone, Rt: FromRead<Read = ReadHalf<TTcpChannel>>, Ip: FromReadTransport<ReadTransport = Rt>, Wt: FromWrite<Write = WriteHalf<TTcpChannel>>, Op: FromWriteTransport<WriteTransport = Wt>, T: FromProtocol<InputProtocol = Ip, OutputProtocol = Op>> MakeThriftConnection for MakeThriftConnectionFromAddrs<T, S>
impl<S: ToSocketAddrs + Clone, Rt: FromRead<Read = ReadHalf<TTcpChannel>>, Ip: FromReadTransport<ReadTransport = Rt>, Wt: FromWrite<Write = WriteHalf<TTcpChannel>>, Op: FromWriteTransport<WriteTransport = Wt>, T: FromProtocol<InputProtocol = Ip, OutputProtocol = Op>> MakeThriftConnection for MakeThriftConnectionFromAddrs<T, S>
Auto Trait Implementations
impl<T, S> RefUnwindSafe for MakeThriftConnectionFromAddrs<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for MakeThriftConnectionFromAddrs<T, S> where
S: Send,
T: Send,
impl<T, S> Sync for MakeThriftConnectionFromAddrs<T, S> where
S: Sync,
T: Sync,
impl<T, S> Unpin for MakeThriftConnectionFromAddrs<T, S> where
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for MakeThriftConnectionFromAddrs<T, S> where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
