@@ -28,10 +28,10 @@ pub struct AttemptId(pub usize);
2828pub struct SpeculativeId ( pub usize ) ;
2929
3030/// Any type implementing this trait can be passed to Session
31- /// to collect execution history of specific queries .\
31+ /// to collect execution history of specific requests .\
3232/// In order to use it call `set_history_listener` on
3333/// `Query`, `PreparedStatement`, etc...\
34- /// The listener has to generate unique IDs for new queries , attempts and speculative fibers.
34+ /// The listener has to generate unique IDs for new requests , attempts and speculative fibers.
3535/// These ids are then used by the caller to identify them.\
3636/// It's important to note that even after a query is finished there still might come events related to it.
3737/// These events come from speculative futures that didn't notice the query is done already.
@@ -131,7 +131,7 @@ impl HistoryCollector {
131131
132132 /// Takes the data out of the collector. The collected events are cleared.\
133133 /// It's possible that after finishing a query and taking out the events
134- /// new ones will still come - from queries that haven't been cancelled yet.
134+ /// new ones will still come - from requests that haven't been cancelled yet.
135135 pub fn take_collected ( & self ) -> HistoryCollectorData {
136136 self . do_with_data ( |data| {
137137 let mut data_to_swap = HistoryCollectorData {
@@ -246,25 +246,25 @@ impl HistoryListener for HistoryCollector {
246246 }
247247}
248248
249- /// Structured representation of queries history.\
249+ /// Structured representation of requests history.\
250250/// HistoryCollector collects raw events which later can be converted
251251/// to this pretty representation.\
252- /// It has a `Display` impl which can be used for printing pretty query history.
252+ /// It has a `Display` impl which can be used for printing pretty request history.
253253#[ derive( Debug , Clone ) ]
254254pub struct StructuredHistory {
255- pub queries : Vec < QueryHistory > ,
255+ pub requests : Vec < RequestHistory > ,
256256}
257257
258258#[ derive( Debug , Clone ) ]
259- pub struct QueryHistory {
259+ pub struct RequestHistory {
260260 pub start_time : TimePoint ,
261261 pub non_speculative_fiber : FiberHistory ,
262262 pub speculative_fibers : Vec < FiberHistory > ,
263- pub result : Option < QueryHistoryResult > ,
263+ pub result : Option < RequestHistoryResult > ,
264264}
265265
266266#[ derive( Debug , Clone ) ]
267- pub enum QueryHistoryResult {
267+ pub enum RequestHistoryResult {
268268 Success ( TimePoint ) ,
269269 Error ( TimePoint , RequestError ) ,
270270}
@@ -291,10 +291,10 @@ pub enum AttemptResult {
291291impl From < & HistoryCollectorData > for StructuredHistory {
292292 fn from ( data : & HistoryCollectorData ) -> StructuredHistory {
293293 let mut attempts: BTreeMap < AttemptId , AttemptHistory > = BTreeMap :: new ( ) ;
294- let mut queries : BTreeMap < RequestId , QueryHistory > = BTreeMap :: new ( ) ;
294+ let mut requests : BTreeMap < RequestId , RequestHistory > = BTreeMap :: new ( ) ;
295295 let mut fibers: BTreeMap < SpeculativeId , FiberHistory > = BTreeMap :: new ( ) ;
296296
297- // Collect basic data about queries , attempts and speculative fibers
297+ // Collect basic data about requests , attempts and speculative fibers
298298 for ( event, event_time) in & data. events {
299299 match event {
300300 HistoryEvent :: NewAttempt ( attempt_id, _, _, node_addr) => {
@@ -324,9 +324,9 @@ impl From<&HistoryCollectorData> for StructuredHistory {
324324 }
325325 }
326326 HistoryEvent :: NewQuery ( request_id) => {
327- queries . insert (
327+ requests . insert (
328328 * request_id,
329- QueryHistory {
329+ RequestHistory {
330330 start_time : * event_time,
331331 non_speculative_fiber : FiberHistory {
332332 start_time : * event_time,
@@ -338,13 +338,14 @@ impl From<&HistoryCollectorData> for StructuredHistory {
338338 ) ;
339339 }
340340 HistoryEvent :: QuerySuccess ( request_id) => {
341- if let Some ( query) = queries . get_mut ( request_id) {
342- query. result = Some ( QueryHistoryResult :: Success ( * event_time) ) ;
341+ if let Some ( query) = requests . get_mut ( request_id) {
342+ query. result = Some ( RequestHistoryResult :: Success ( * event_time) ) ;
343343 }
344344 }
345345 HistoryEvent :: QueryError ( request_id, error) => {
346- if let Some ( query) = queries. get_mut ( request_id) {
347- query. result = Some ( QueryHistoryResult :: Error ( * event_time, error. clone ( ) ) ) ;
346+ if let Some ( query) = requests. get_mut ( request_id) {
347+ query. result =
348+ Some ( RequestHistoryResult :: Error ( * event_time, error. clone ( ) ) ) ;
348349 }
349350 }
350351 HistoryEvent :: NewSpeculativeFiber ( speculative_id, _) => {
@@ -370,7 +371,7 @@ impl From<&HistoryCollectorData> for StructuredHistory {
370371 }
371372 }
372373 None => {
373- if let Some ( query) = queries . get_mut ( request_id) {
374+ if let Some ( query) = requests . get_mut ( request_id) {
374375 query. non_speculative_fiber . attempts . push ( attempt) ;
375376 }
376377 }
@@ -379,19 +380,19 @@ impl From<&HistoryCollectorData> for StructuredHistory {
379380 }
380381 }
381382
382- // Move speculative fibers to their queries
383+ // Move speculative fibers to their requests
383384 for ( event, _) in & data. events {
384385 if let HistoryEvent :: NewSpeculativeFiber ( speculative_id, request_id) = event {
385386 if let Some ( fiber) = fibers. remove ( speculative_id) {
386- if let Some ( query) = queries . get_mut ( request_id) {
387+ if let Some ( query) = requests . get_mut ( request_id) {
387388 query. speculative_fibers . push ( fiber) ;
388389 }
389390 }
390391 }
391392 }
392393
393394 StructuredHistory {
394- queries : queries . into_values ( ) . collect ( ) ,
395+ requests : requests . into_values ( ) . collect ( ) ,
395396 }
396397 }
397398}
@@ -400,7 +401,7 @@ impl From<&HistoryCollectorData> for StructuredHistory {
400401impl Display for StructuredHistory {
401402 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
402403 writeln ! ( f, "Queries History:" ) ?;
403- for ( i, query) in self . queries . iter ( ) . enumerate ( ) {
404+ for ( i, query) in self . requests . iter ( ) . enumerate ( ) {
404405 writeln ! ( f, "=== Query #{} ===" , i) ?;
405406 writeln ! ( f, "| start_time: {}" , query. start_time) ?;
406407 writeln ! ( f, "| Non-speculative attempts:" ) ?;
@@ -414,10 +415,10 @@ impl Display for StructuredHistory {
414415 }
415416 writeln ! ( f, "|" ) ?;
416417 match & query. result {
417- Some ( QueryHistoryResult :: Success ( succ_time) ) => {
418+ Some ( RequestHistoryResult :: Success ( succ_time) ) => {
418419 writeln ! ( f, "| Query successful at {}" , succ_time) ?;
419420 }
420- Some ( QueryHistoryResult :: Error ( err_time, error) ) => {
421+ Some ( RequestHistoryResult :: Error ( err_time, error) ) => {
421422 writeln ! ( f, "| Query failed at {}" , err_time) ?;
422423 writeln ! ( f, "| Error: {}" , error) ?;
423424 }
@@ -461,8 +462,8 @@ mod tests {
461462 } ;
462463
463464 use super :: {
464- AttemptId , AttemptResult , HistoryCollector , HistoryListener , QueryHistoryResult , RequestId ,
465- SpeculativeId , StructuredHistory , TimePoint ,
465+ AttemptId , AttemptResult , HistoryCollector , HistoryListener , RequestHistoryResult ,
466+ RequestId , SpeculativeId , StructuredHistory , TimePoint ,
466467 } ;
467468 use assert_matches:: assert_matches;
468469 use chrono:: { DateTime , NaiveDate , NaiveDateTime , NaiveTime , Utc } ;
@@ -480,11 +481,11 @@ mod tests {
480481 Utc ,
481482 ) ;
482483
483- for query in & mut history. queries {
484+ for query in & mut history. requests {
484485 query. start_time = the_time;
485486 match & mut query. result {
486- Some ( QueryHistoryResult :: Success ( succ_time) ) => * succ_time = the_time,
487- Some ( QueryHistoryResult :: Error ( err_time, _) ) => * err_time = the_time,
487+ Some ( RequestHistoryResult :: Success ( succ_time) ) => * succ_time = the_time,
488+ Some ( RequestHistoryResult :: Error ( err_time, _) ) => * err_time = the_time,
488489 None => { }
489490 } ;
490491
@@ -543,7 +544,7 @@ mod tests {
543544 let history_collector = HistoryCollector :: new ( ) ;
544545 let history: StructuredHistory = history_collector. clone_structured_history ( ) ;
545546
546- assert ! ( history. queries . is_empty( ) ) ;
547+ assert ! ( history. requests . is_empty( ) ) ;
547548
548549 let displayed = "Queries History:
549550" ;
@@ -559,9 +560,12 @@ mod tests {
559560
560561 let history: StructuredHistory = history_collector. clone_structured_history ( ) ;
561562
562- assert_eq ! ( history. queries. len( ) , 1 ) ;
563- assert ! ( history. queries[ 0 ] . non_speculative_fiber. attempts. is_empty( ) ) ;
564- assert ! ( history. queries[ 0 ] . speculative_fibers. is_empty( ) ) ;
563+ assert_eq ! ( history. requests. len( ) , 1 ) ;
564+ assert ! ( history. requests[ 0 ]
565+ . non_speculative_fiber
566+ . attempts
567+ . is_empty( ) ) ;
568+ assert ! ( history. requests[ 0 ] . speculative_fibers. is_empty( ) ) ;
565569
566570 let displayed = "Queries History:
567571=== Query #0 ===
@@ -588,11 +592,11 @@ mod tests {
588592
589593 let history: StructuredHistory = history_collector. clone_structured_history ( ) ;
590594
591- assert_eq ! ( history. queries . len( ) , 1 ) ;
592- assert_eq ! ( history. queries [ 0 ] . non_speculative_fiber. attempts. len( ) , 1 ) ;
593- assert ! ( history. queries [ 0 ] . speculative_fibers. is_empty( ) ) ;
595+ assert_eq ! ( history. requests . len( ) , 1 ) ;
596+ assert_eq ! ( history. requests [ 0 ] . non_speculative_fiber. attempts. len( ) , 1 ) ;
597+ assert ! ( history. requests [ 0 ] . speculative_fibers. is_empty( ) ) ;
594598 assert_matches ! (
595- history. queries [ 0 ] . non_speculative_fiber. attempts[ 0 ] . result,
599+ history. requests [ 0 ] . non_speculative_fiber. attempts[ 0 ] . result,
596600 Some ( AttemptResult :: Success ( _) )
597601 ) ;
598602
@@ -676,12 +680,21 @@ mod tests {
676680
677681 let history: StructuredHistory = history_collector. clone_structured_history ( ) ;
678682
679- assert_eq ! ( history. queries. len( ) , 1 ) ;
680- assert ! ( history. queries[ 0 ] . non_speculative_fiber. attempts. is_empty( ) ) ;
681- assert_eq ! ( history. queries[ 0 ] . speculative_fibers. len( ) , 3 ) ;
682- assert ! ( history. queries[ 0 ] . speculative_fibers[ 0 ] . attempts. is_empty( ) ) ;
683- assert ! ( history. queries[ 0 ] . speculative_fibers[ 1 ] . attempts. is_empty( ) ) ;
684- assert ! ( history. queries[ 0 ] . speculative_fibers[ 2 ] . attempts. is_empty( ) ) ;
683+ assert_eq ! ( history. requests. len( ) , 1 ) ;
684+ assert ! ( history. requests[ 0 ]
685+ . non_speculative_fiber
686+ . attempts
687+ . is_empty( ) ) ;
688+ assert_eq ! ( history. requests[ 0 ] . speculative_fibers. len( ) , 3 ) ;
689+ assert ! ( history. requests[ 0 ] . speculative_fibers[ 0 ]
690+ . attempts
691+ . is_empty( ) ) ;
692+ assert ! ( history. requests[ 0 ] . speculative_fibers[ 1 ]
693+ . attempts
694+ . is_empty( ) ) ;
695+ assert ! ( history. requests[ 0 ] . speculative_fibers[ 2 ]
696+ . attempts
697+ . is_empty( ) ) ;
685698
686699 let displayed = "Queries History:
687700=== Query #0 ===
@@ -813,7 +826,7 @@ mod tests {
813826 }
814827
815828 #[ test]
816- fn multiple_queries ( ) {
829+ fn multiple_requests ( ) {
817830 setup_tracing ( ) ;
818831 let history_collector = HistoryCollector :: new ( ) ;
819832
0 commit comments