@@ -8,10 +8,7 @@ use crate::{
88 frame:: { FrameOpcode , FrameParams , RequestFrame , RequestOpcode , ResponseFrame , ResponseOpcode } ,
99 TargetShard ,
1010} ;
11- use scylla_cql:: {
12- errors:: { DbError , WriteType } ,
13- Consistency ,
14- } ;
11+ use scylla_cql:: errors:: DbError ;
1512
1613/// Specifies when an associated [Reaction] will be performed.
1714/// Conditions are subject to logic, with `not()`, `and()` and `or()`
@@ -407,8 +404,13 @@ impl RequestReaction {
407404 }
408405}
409406
410- struct ExampleDbErrors ;
411- impl ExampleDbErrors {
407+ pub mod example_db_errors {
408+ use bytes:: Bytes ;
409+ use scylla_cql:: {
410+ errors:: { DbError , WriteType } ,
411+ Consistency ,
412+ } ;
413+
412414 pub fn syntax_error ( ) -> DbError {
413415 DbError :: SyntaxError
414416 }
@@ -507,84 +509,84 @@ pub struct ResponseForger;
507509
508510impl ResponseForger {
509511 pub fn syntax_error ( & self ) -> RequestReaction {
510- RequestReaction :: forge_with_error ( ExampleDbErrors :: syntax_error ( ) )
512+ RequestReaction :: forge_with_error ( example_db_errors :: syntax_error ( ) )
511513 }
512514 pub fn invalid ( & self ) -> RequestReaction {
513- RequestReaction :: forge_with_error ( ExampleDbErrors :: invalid ( ) )
515+ RequestReaction :: forge_with_error ( example_db_errors :: invalid ( ) )
514516 }
515517 pub fn already_exists ( & self ) -> RequestReaction {
516- RequestReaction :: forge_with_error ( ExampleDbErrors :: already_exists ( ) )
518+ RequestReaction :: forge_with_error ( example_db_errors :: already_exists ( ) )
517519 }
518520 pub fn function_failure ( & self ) -> RequestReaction {
519- RequestReaction :: forge_with_error ( ExampleDbErrors :: function_failure ( ) )
521+ RequestReaction :: forge_with_error ( example_db_errors :: function_failure ( ) )
520522 }
521523 pub fn authentication_error ( & self ) -> RequestReaction {
522- RequestReaction :: forge_with_error ( ExampleDbErrors :: authentication_error ( ) )
524+ RequestReaction :: forge_with_error ( example_db_errors :: authentication_error ( ) )
523525 }
524526 pub fn unauthorized ( & self ) -> RequestReaction {
525- RequestReaction :: forge_with_error ( ExampleDbErrors :: unauthorized ( ) )
527+ RequestReaction :: forge_with_error ( example_db_errors :: unauthorized ( ) )
526528 }
527529 pub fn config_error ( & self ) -> RequestReaction {
528- RequestReaction :: forge_with_error ( ExampleDbErrors :: config_error ( ) )
530+ RequestReaction :: forge_with_error ( example_db_errors :: config_error ( ) )
529531 }
530532 pub fn unavailable ( & self ) -> RequestReaction {
531- RequestReaction :: forge_with_error ( ExampleDbErrors :: unavailable ( ) )
533+ RequestReaction :: forge_with_error ( example_db_errors :: unavailable ( ) )
532534 }
533535 pub fn overloaded ( & self ) -> RequestReaction {
534- RequestReaction :: forge_with_error ( ExampleDbErrors :: overloaded ( ) )
536+ RequestReaction :: forge_with_error ( example_db_errors :: overloaded ( ) )
535537 }
536538 pub fn is_bootstrapping ( & self ) -> RequestReaction {
537- RequestReaction :: forge_with_error ( ExampleDbErrors :: is_bootstrapping ( ) )
539+ RequestReaction :: forge_with_error ( example_db_errors :: is_bootstrapping ( ) )
538540 }
539541 pub fn truncate_error ( & self ) -> RequestReaction {
540- RequestReaction :: forge_with_error ( ExampleDbErrors :: truncate_error ( ) )
542+ RequestReaction :: forge_with_error ( example_db_errors :: truncate_error ( ) )
541543 }
542544 pub fn read_timeout ( & self ) -> RequestReaction {
543- RequestReaction :: forge_with_error ( ExampleDbErrors :: read_timeout ( ) )
545+ RequestReaction :: forge_with_error ( example_db_errors :: read_timeout ( ) )
544546 }
545547 pub fn write_timeout ( & self ) -> RequestReaction {
546- RequestReaction :: forge_with_error ( ExampleDbErrors :: write_timeout ( ) )
548+ RequestReaction :: forge_with_error ( example_db_errors :: write_timeout ( ) )
547549 }
548550 pub fn read_failure ( & self ) -> RequestReaction {
549- RequestReaction :: forge_with_error ( ExampleDbErrors :: read_failure ( ) )
551+ RequestReaction :: forge_with_error ( example_db_errors :: read_failure ( ) )
550552 }
551553 pub fn write_failure ( & self ) -> RequestReaction {
552- RequestReaction :: forge_with_error ( ExampleDbErrors :: write_failure ( ) )
554+ RequestReaction :: forge_with_error ( example_db_errors :: write_failure ( ) )
553555 }
554556 pub fn unprepared ( & self ) -> RequestReaction {
555- RequestReaction :: forge_with_error ( ExampleDbErrors :: unprepared ( ) )
557+ RequestReaction :: forge_with_error ( example_db_errors :: unprepared ( ) )
556558 }
557559 pub fn server_error ( & self ) -> RequestReaction {
558- RequestReaction :: forge_with_error ( ExampleDbErrors :: server_error ( ) )
560+ RequestReaction :: forge_with_error ( example_db_errors :: server_error ( ) )
559561 }
560562 pub fn protocol_error ( & self ) -> RequestReaction {
561- RequestReaction :: forge_with_error ( ExampleDbErrors :: protocol_error ( ) )
563+ RequestReaction :: forge_with_error ( example_db_errors :: protocol_error ( ) )
562564 }
563565 pub fn other ( & self , num : i32 ) -> RequestReaction {
564- RequestReaction :: forge_with_error ( ExampleDbErrors :: other ( num) )
566+ RequestReaction :: forge_with_error ( example_db_errors :: other ( num) )
565567 }
566568 pub fn random_error ( & self ) -> RequestReaction {
567569 self . random_error_with_delay ( None )
568570 }
569571 pub fn random_error_with_delay ( & self , delay : Option < Duration > ) -> RequestReaction {
570572 static ERRORS : & [ fn ( ) -> DbError ] = & [
571- ExampleDbErrors :: invalid,
572- ExampleDbErrors :: already_exists,
573- ExampleDbErrors :: function_failure,
574- ExampleDbErrors :: authentication_error,
575- ExampleDbErrors :: unauthorized,
576- ExampleDbErrors :: config_error,
577- ExampleDbErrors :: unavailable,
578- ExampleDbErrors :: overloaded,
579- ExampleDbErrors :: is_bootstrapping,
580- ExampleDbErrors :: truncate_error,
581- ExampleDbErrors :: read_timeout,
582- ExampleDbErrors :: write_timeout,
583- ExampleDbErrors :: write_failure,
584- ExampleDbErrors :: unprepared,
585- ExampleDbErrors :: server_error,
586- ExampleDbErrors :: protocol_error,
587- || ExampleDbErrors :: other ( 2137 ) ,
573+ example_db_errors :: invalid,
574+ example_db_errors :: already_exists,
575+ example_db_errors :: function_failure,
576+ example_db_errors :: authentication_error,
577+ example_db_errors :: unauthorized,
578+ example_db_errors :: config_error,
579+ example_db_errors :: unavailable,
580+ example_db_errors :: overloaded,
581+ example_db_errors :: is_bootstrapping,
582+ example_db_errors :: truncate_error,
583+ example_db_errors :: read_timeout,
584+ example_db_errors :: write_timeout,
585+ example_db_errors :: write_failure,
586+ example_db_errors :: unprepared,
587+ example_db_errors :: server_error,
588+ example_db_errors :: protocol_error,
589+ || example_db_errors :: other ( 2137 ) ,
588590 ] ;
589591 RequestReaction :: forge_with_error_lazy_delay (
590592 Box :: new ( || ERRORS [ rand:: thread_rng ( ) . next_u32 ( ) as usize % ERRORS . len ( ) ] ( ) ) ,
0 commit comments