File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,9 +12,9 @@ fn main() {
1212
1313 // Subscribe to "data1"
1414 let _sub_data1 = session
15- . declare_subscriber ( "UserDefined/test/data1 " )
15+ . declare_subscriber ( "system/emergency/hazard_status " )
1616 . callback ( |sample| {
17- handle_sample ( "UserDefined/test/data1 " , sample. payload ( ) . to_bytes ( ) ) ;
17+ handle_sample ( "system/emergency/hazard_status " , sample. payload ( ) . to_bytes ( ) ) ;
1818 } )
1919 . background ( )
2020 . wait ( )
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ fn main() {
1515
1616 // Publisher 1: user-specified priority
1717 let pub1 = session
18- . declare_publisher ( "UserDefined/test/data1 " )
18+ . declare_publisher ( "system/emergency/hazard_status " )
1919 . congestion_control ( CongestionControl :: Block )
2020 . priority ( user_priority)
2121 . express ( express)
Original file line number Diff line number Diff line change @@ -1234,15 +1234,18 @@ pub struct TopicInfo {
12341234 pub bandwidth : String ,
12351235}
12361236
1237- pub static TOPIC_TABLE : OnceCell < Vec < TopicInfo > > = OnceCell :: new ( ) ;
1237+ pub static TOPIC_TABLE : OnceCell < HashMap < String , TopicInfo > > = OnceCell :: new ( ) ;
12381238
1239- fn read_topic_table ( path : & str ) -> Vec < TopicInfo > {
1239+ fn read_topic_table ( path : & str ) -> HashMap < String , TopicInfo > {
12401240 let mut rdr = csv:: ReaderBuilder :: new ( )
12411241 . has_headers ( false )
12421242 . from_path ( path)
12431243 . expect ( "Cannot open CSV" ) ;
12441244 rdr. deserialize ( )
1245- . map ( |res| res. expect ( "CSV parse error" ) )
1245+ . map ( |res| {
1246+ let info: TopicInfo = res. expect ( "CSV parse error" ) ;
1247+ ( info. topic . clone ( ) , info)
1248+ } )
12461249 . collect ( )
12471250}
12481251
Original file line number Diff line number Diff line change @@ -304,13 +304,9 @@ pub fn route_data(
304304 let flow_name = format ! ( "{}{}" , prefix. expr( ) , wire_expr. suffix. as_ref( ) ) ;
305305
306306 if let Some ( table) = TOPIC_TABLE . get ( ) {
307- for info in table {
308- if info. topic == flow_name {
309- println ! ( "Match: {:?}" , info) ;
310- }
307+ if let Some ( info) = table. get ( & flow_name) {
308+ tracing:: debug!( "Match: {:?}" , info) ;
311309 }
312- } else {
313- println ! ( "TOPIC_TABLE not initialized" ) ;
314310 }
315311
316312 tracing:: trace!(
You can’t perform that action at this time.
0 commit comments