pub struct TestingWrapperBuilder<S: AppState> { /* private fields */ }Expand description
Builder for creating a testing wrapper with custom configuration
Implementations§
Source§impl<S: AppState> TestingWrapperBuilder<S>
impl<S: AppState> TestingWrapperBuilder<S>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 140)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_stats_interval(self, interval: Duration) -> Self
pub fn with_stats_interval(self, interval: Duration) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 141)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_log_stats(self, log_stats: bool) -> Self
pub fn with_log_stats(self, log_stats: bool) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 142)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_track_events(self, track_events: bool) -> Self
pub fn with_track_events(self, track_events: bool) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 143)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_max_reconnect_attempts(self, max_attempts: Option<u32>) -> Self
pub fn with_max_reconnect_attempts(self, max_attempts: Option<u32>) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 144)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_reconnect_delay(self, delay: Duration) -> Self
pub fn with_reconnect_delay(self, delay: Duration) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 145)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_connection_timeout(self, timeout: Duration) -> Self
pub fn with_connection_timeout(self, timeout: Duration) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 146)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Sourcepub fn with_auto_reconnect(self, auto_reconnect: bool) -> Self
pub fn with_auto_reconnect(self, auto_reconnect: bool) -> Self
Examples found in repository?
examples/testing_echo_client.rs (line 147)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }pub fn build( self, client: Client<S>, runner: ClientRunner<S>, ) -> TestingWrapper<S>
Sourcepub async fn build_with_middleware(
self,
builder: ClientBuilder<S>,
) -> CoreResult<TestingWrapper<S>>
pub async fn build_with_middleware( self, builder: ClientBuilder<S>, ) -> CoreResult<TestingWrapper<S>>
Build the testing wrapper and return both the wrapper and a compatible middleware
Examples found in repository?
examples/testing_echo_client.rs (line 148)
124 pub async fn new(url: String) -> CoreResult<Self> {
125 let connector = DummyConnector::new(url);
126
127 let builder = ClientBuilder::new(connector, ()).with_module::<EchoModule>();
128
129 // // Create testing wrapper with custom configuration
130 // let testing_config = TestingConfig {
131 // stats_interval: Duration::from_secs(10), // Log stats every 10 seconds
132 // log_stats: true,
133 // track_events: true,
134 // max_reconnect_attempts: Some(3),
135 // reconnect_delay: Duration::from_secs(5),
136 // connection_timeout: Duration::from_secs(30),
137 // auto_reconnect: true,
138 // };
139
140 let testing_wrapper = TestingWrapperBuilder::new()
141 .with_stats_interval(Duration::from_secs(10))
142 .with_log_stats(true)
143 .with_track_events(true)
144 .with_max_reconnect_attempts(Some(3))
145 .with_reconnect_delay(Duration::from_secs(5))
146 .with_connection_timeout(Duration::from_secs(30))
147 .with_auto_reconnect(true)
148 .build_with_middleware(builder)
149 .await?;
150
151 Ok(Self { testing_wrapper })
152 }Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for TestingWrapperBuilder<S>
impl<S> RefUnwindSafe for TestingWrapperBuilder<S>where
S: RefUnwindSafe,
impl<S> Send for TestingWrapperBuilder<S>
impl<S> Sync for TestingWrapperBuilder<S>
impl<S> Unpin for TestingWrapperBuilder<S>where
S: Unpin,
impl<S> UnsafeUnpin for TestingWrapperBuilder<S>
impl<S> UnwindSafe for TestingWrapperBuilder<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more