55
66mod protocols;
77mod utils;
8- #[ cfg( unix) ]
98use protocols:: asynchronous:: { empty, streaming, streaming_ttrpc} ;
109use ttrpc:: context:: { self , Context } ;
11- #[ cfg( unix) ]
1210use ttrpc:: r#async:: Client ;
1311
14- #[ cfg( windows) ]
15- fn main ( ) {
16- println ! ( "This example only works on Unix-like OSes" ) ;
17- }
18-
19- #[ cfg( unix) ]
2012#[ tokio:: main( flavor = "current_thread" ) ]
2113async fn main ( ) {
2214 simple_logging:: log_to_stderr ( log:: LevelFilter :: Info ) ;
2315
24- let c = Client :: connect ( utils:: SOCK_ADDR ) . unwrap ( ) ;
16+ let c = Client :: connect ( utils:: SOCK_ADDR ) . await . unwrap ( ) ;
2517 let sc = streaming_ttrpc:: StreamingClient :: new ( c) ;
2618
2719 let _now = std:: time:: Instant :: now ( ) ;
@@ -75,7 +67,6 @@ fn default_ctx() -> Context {
7567 ctx
7668}
7769
78- #[ cfg( unix) ]
7970async fn echo_request ( cli : streaming_ttrpc:: StreamingClient ) {
8071 let echo1 = streaming:: EchoPayload {
8172 seq : 1 ,
@@ -87,7 +78,6 @@ async fn echo_request(cli: streaming_ttrpc::StreamingClient) {
8778 assert_eq ! ( resp. seq, echo1. seq + 1 ) ;
8879}
8980
90- #[ cfg( unix) ]
9181async fn echo_stream ( cli : streaming_ttrpc:: StreamingClient ) {
9282 let mut stream = cli. echo_stream ( default_ctx ( ) ) . await . unwrap ( ) ;
9383
@@ -110,7 +100,6 @@ async fn echo_stream(cli: streaming_ttrpc::StreamingClient) {
110100 assert ! ( matches!( ret, Err ( ttrpc:: Error :: Eof ) ) ) ;
111101}
112102
113- #[ cfg( unix) ]
114103async fn sum_stream ( cli : streaming_ttrpc:: StreamingClient ) {
115104 let mut stream = cli. sum_stream ( default_ctx ( ) ) . await . unwrap ( ) ;
116105
@@ -138,7 +127,6 @@ async fn sum_stream(cli: streaming_ttrpc::StreamingClient) {
138127 assert_eq ! ( ssum. num, sum. num) ;
139128}
140129
141- #[ cfg( unix) ]
142130async fn divide_stream ( cli : streaming_ttrpc:: StreamingClient ) {
143131 let expected = streaming:: Sum {
144132 sum : 392 ,
@@ -158,7 +146,6 @@ async fn divide_stream(cli: streaming_ttrpc::StreamingClient) {
158146 assert_eq ! ( actual. num, expected. num) ;
159147}
160148
161- #[ cfg( unix) ]
162149async fn echo_null ( cli : streaming_ttrpc:: StreamingClient ) {
163150 let mut stream = cli. echo_null ( default_ctx ( ) ) . await . unwrap ( ) ;
164151
@@ -174,7 +161,6 @@ async fn echo_null(cli: streaming_ttrpc::StreamingClient) {
174161 assert_eq ! ( res, empty:: Empty :: new( ) ) ;
175162}
176163
177- #[ cfg( unix) ]
178164async fn echo_null_stream ( cli : streaming_ttrpc:: StreamingClient ) {
179165 let stream = cli. echo_null_stream ( default_ctx ( ) ) . await . unwrap ( ) ;
180166
@@ -206,7 +192,6 @@ async fn echo_null_stream(cli: streaming_ttrpc::StreamingClient) {
206192 . unwrap ( ) ;
207193}
208194
209- #[ cfg( unix) ]
210195async fn echo_default_value ( cli : streaming_ttrpc:: StreamingClient ) {
211196 let mut stream = cli
212197 . echo_default_value ( default_ctx ( ) , & Default :: default ( ) ) // send default value to verify #208
@@ -219,7 +204,6 @@ async fn echo_default_value(cli: streaming_ttrpc::StreamingClient) {
219204 assert_eq ! ( received. msg, "" ) ;
220205}
221206
222- #[ cfg( unix) ]
223207async fn server_send_stream ( cli : streaming_ttrpc:: StreamingClient ) {
224208 let mut stream = cli
225209 . server_send_stream ( default_ctx ( ) , & Default :: default ( ) )
0 commit comments