Skip to main content

TestingWrapperBuilder

Struct TestingWrapperBuilder 

Source
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>

Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

pub fn build( self, client: Client<S>, runner: ClientRunner<S>, ) -> TestingWrapper<S>

Source

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§

Source§

impl<S: AppState> Default for TestingWrapperBuilder<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more