Responder

Struct Responder 

Source
pub struct Responder<Req, Resp>
where Req: Send + Sync + 'static, Resp: Send + Sync + 'static,
{ /* private fields */ }
Expand description

A responder that processes incoming requests and sends back responses.

The responder supports both fixed and dynamic concurrency strategies.

§Type Parameters

  • Req: The type of the request, must be Send + Sync + 'static.
  • Resp: The type of the response, must be Send + Sync + 'static.
  • Fut: The future returned by the request handler.
  • F: The type of the request handler function.

Implementations§

Source§

impl<Req, Resp> Responder<Req, Resp>
where Req: Send + Sync + 'static, Resp: Send + Sync + 'static,

Source

pub async fn process_requests_with_strategy( self, strategy: ConcurrencyStrategy, ) -> Result<(), Error>

Processes incoming requests using the specified concurrency strategy.

§Parameters
  • strategy: The concurrency strategy to use (Fixed or Dynamic).
§Returns
  • Ok(()): If all requests are processed successfully.
  • Err(Error): If an error occurs during processing.
Source

pub async fn process_requests(self) -> Result<(), Error>

Processes incoming requests with a fixed concurrency of 16.

§Returns
  • Ok(()): If all requests are processed successfully.
  • Err(Error): If an error occurs during processing.
Source

pub async fn process_requests_fixed( self, concurrency: usize, ) -> Result<(), Error>

Processes incoming requests with a fixed concurrency.

§Parameters
  • concurrency: The number of concurrent requests to process.
§Returns
  • Ok(()): If all requests are processed successfully.
  • Err(Error): If an error occurs during processing.
Source

pub async fn process_requests_dynamic( self, initial_concurrency: usize, max_concurrency: usize, ) -> Result<(), Error>

Processes incoming requests with dynamic concurrency adjustment.

The concurrency is adjusted based on the response time of requests.

§Parameters
  • initial_concurrency: The initial number of concurrent requests.
  • max_concurrency: The maximum number of concurrent requests.
§Returns
  • Ok(()): If all requests are processed successfully.
  • Err(Error): If an error occurs during processing.

Auto Trait Implementations§

§

impl<Req, Resp> Freeze for Responder<Req, Resp>

§

impl<Req, Resp> !RefUnwindSafe for Responder<Req, Resp>

§

impl<Req, Resp> Send for Responder<Req, Resp>

§

impl<Req, Resp> !Sync for Responder<Req, Resp>

§

impl<Req, Resp> Unpin for Responder<Req, Resp>

§

impl<Req, Resp> !UnwindSafe for Responder<Req, Resp>

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, 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, 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.