@@ -18,6 +18,7 @@ use nix::sys::socket::*;
1818use protocols:: sync:: { agent, agent_ttrpc, health, health_ttrpc} ;
1919use std:: thread;
2020use ttrpc:: client:: Client ;
21+ use ttrpc:: context:: { self , Context } ;
2122
2223fn main ( ) {
2324 let path = "/tmp/1" ;
@@ -55,7 +56,7 @@ fn main() {
5556 "OS Thread {:?} - {} -> {:?} ended: {:?}" ,
5657 std:: thread:: current( ) . id( ) ,
5758 "health.check()" ,
58- thc. check( & req , 0 ) ,
59+ thc. check( default_ctx ( ) , & req ) ,
5960 now. elapsed( ) ,
6061 ) ;
6162 } ) ;
@@ -68,7 +69,7 @@ fn main() {
6869 now. elapsed( ) ,
6970 ) ;
7071
71- let show = match tac. list_interfaces ( & agent:: ListInterfacesRequest :: new ( ) , 0 ) {
72+ let show = match tac. list_interfaces ( default_ctx ( ) , & agent:: ListInterfacesRequest :: new ( ) ) {
7273 Err ( e) => format ! ( "{:?}" , e) ,
7374 Ok ( s) => format ! ( "{:?}" , s) ,
7475 } ;
@@ -87,7 +88,7 @@ fn main() {
8788 "agent.online_cpu_mem()" ,
8889 now. elapsed( )
8990 ) ;
90- let show = match ac. online_cpu_mem ( & agent:: OnlineCPUMemRequest :: new ( ) , 0 ) {
91+ let show = match ac. online_cpu_mem ( default_ctx ( ) , & agent:: OnlineCPUMemRequest :: new ( ) ) {
9192 Err ( e) => format ! ( "{:?}" , e) ,
9293 Ok ( s) => format ! ( "{:?}" , s) ,
9394 } ;
@@ -108,10 +109,19 @@ fn main() {
108109 println ! (
109110 "Main OS Thread - {} -> {:?} ended: {:?}" ,
110111 "health.version()" ,
111- hc. version( & health:: CheckRequest :: new( ) , 0 ) ,
112+ hc. version( default_ctx ( ) , & health:: CheckRequest :: new( ) ) ,
112113 now. elapsed( )
113114 ) ;
114115
115116 t. join ( ) . unwrap ( ) ;
116117 t2. join ( ) . unwrap ( ) ;
117118}
119+
120+ fn default_ctx ( ) -> Context {
121+ let mut ctx = context:: with_timeout ( 0 ) ;
122+ ctx. add ( "key-1" . to_string ( ) , "value-1-1" . to_string ( ) ) ;
123+ ctx. add ( "key-1" . to_string ( ) , "value-1-2" . to_string ( ) ) ;
124+ ctx. set ( "key-2" . to_string ( ) , vec ! [ "value-2" . to_string( ) ] ) ;
125+
126+ ctx
127+ }
0 commit comments