MCPcopy Create free account
hub / github.com/apache/thrift / new_client

Function new_client

tutorial/rs/src/bin/tutorial_client.rs:102–126  ·  view source on GitHub ↗
(
    host: &str,
    port: u16,
)

Source from the content-addressed store, hash-verified

100type ClientOutputProtocol = TCompactOutputProtocol<TFramedWriteTransport<WriteHalf<TTcpChannel>>>;
101
102fn new_client(
103 host: &str,
104 port: u16,
105) -> thrift::Result<CalculatorSyncClient<ClientInputProtocol, ClientOutputProtocol>> {
106 let mut c = TTcpChannel::new();
107
108 // open the underlying TCP stream
109 println!("connecting to tutorial server on {}:{}", host, port);
110 c.open(format!("{}:{}", host, port))?;
111
112 // clone the TCP channel into two halves, one which
113 // we'll use for reading, the other for writing
114 let (i_chan, o_chan) = c.split()?;
115
116 // wrap the raw sockets (slow) with a buffered transport of some kind
117 let i_tran = TFramedReadTransport::new(i_chan);
118 let o_tran = TFramedWriteTransport::new(o_chan);
119
120 // now create the protocol implementations
121 let i_prot = TCompactInputProtocol::new(i_tran);
122 let o_prot = TCompactOutputProtocol::new(o_tran);
123
124 // we're done!
125 Ok(CalculatorSyncClient::new(i_prot, o_prot))
126}

Callers 1

runFunction · 0.85

Calls 2

openMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected