Skip to main content

TestingWrapper

Struct TestingWrapper 

Source
pub struct TestingWrapper<S: AppState> { /* private fields */ }
Expand description

A testing wrapper around the Client that provides comprehensive statistics and monitoring capabilities for WebSocket connections.

Implementations§

Source§

impl<S: AppState> TestingWrapper<S>

Source

pub fn new( client: Client<S>, runner: ClientRunner<S>, config: TestingConfig, ) -> Self

Create a new testing wrapper with the provided client and runner

Source

pub fn new_with_stats( client: Client<S>, runner: ClientRunner<S>, config: TestingConfig, stats: Arc<StatisticsTracker>, ) -> Self

Create a new testing wrapper with a shared StatisticsTracker This is useful when you want to share statistics between multiple components

Source

pub fn create_middleware(&self) -> TestingMiddleware<S>

Create a TestingMiddleware that shares the same StatisticsTracker

Source

pub async fn start(&mut self) -> CoreResult<()>

Start the testing wrapper, which will run the client and begin collecting statistics

Examples found in repository?
examples/testing_echo_client.rs (line 155)
154    pub async fn start(&mut self) -> CoreResult<()> {
155        self.testing_wrapper.start().await
156    }
Source

pub async fn stop(self) -> CoreResult<ConnectionStats>

Stop the testing wrapper

Examples found in repository?
examples/testing_echo_client.rs (line 159)
158    pub async fn stop(self) -> CoreResult<()> {
159        self.testing_wrapper.stop().await?;
160        Ok(())
161    }
Source

pub async fn get_stats(&self) -> ConnectionStats

Get the current connection statistics

Examples found in repository?
examples/testing_echo_client.rs (line 176)
175    pub async fn get_stats(&self) -> binary_options_tools_core_pre::statistics::ConnectionStats {
176        self.testing_wrapper.get_stats().await
177    }
Source

pub fn client(&self) -> &Client<S>

Get a reference to the underlying client

Examples found in repository?
examples/testing_echo_client.rs (line 166)
163    pub async fn echo(&self, msg: String) -> CoreResult<String> {
164        match self
165            .testing_wrapper
166            .client()
167            .get_handle::<EchoModule>()
168            .await
169        {
170            Some(echo_handle) => echo_handle.echo(msg).await,
171            None => Err(CoreError::ModuleNotFound("EchoModule".to_string())),
172        }
173    }
Source

pub fn client_mut(&mut self) -> &mut Client<S>

Get a mutable reference to the underlying client

Source

pub async fn reset_stats(&self)

Reset all statistics

Source

pub async fn export_stats_json(&self) -> CoreResult<String>

Export statistics to JSON

Examples found in repository?
examples/testing_echo_client.rs (line 180)
179    pub async fn export_stats_json(&self) -> CoreResult<String> {
180        self.testing_wrapper.export_stats_json().await
181    }
Source

pub async fn export_stats_csv(&self) -> CoreResult<String>

Export statistics to CSV

Examples found in repository?
examples/testing_echo_client.rs (line 184)
183    pub async fn export_stats_csv(&self) -> CoreResult<String> {
184        self.testing_wrapper.export_stats_csv().await
185    }

Auto Trait Implementations§

§

impl<S> Freeze for TestingWrapper<S>

§

impl<S> !RefUnwindSafe for TestingWrapper<S>

§

impl<S> Send for TestingWrapper<S>

§

impl<S> Sync for TestingWrapper<S>

§

impl<S> Unpin for TestingWrapper<S>

§

impl<S> UnsafeUnpin for TestingWrapper<S>

§

impl<S> !UnwindSafe for TestingWrapper<S>

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