HandlerState

Trait HandlerState 

Source
pub trait HandlerState:
    'static
    + Sync
    + Send {
    type StoreData: Send;

    // Required methods
    fn new_store(
        &self,
        req_id: Option<u64>,
    ) -> Result<StoreBundle<Self::StoreData>>;
    fn request_timeout(&self) -> Duration;
    fn idle_instance_timeout(&self) -> Duration;
    fn max_instance_reuse_count(&self) -> usize;
    fn max_instance_concurrent_reuse_count(&self) -> usize;
    fn handle_worker_error(&self, error: Error);
}
Available on crate feature component-model-async only.
Expand description

Represents the application-specific state of a web server.

Required Associated Types§

Source

type StoreData: Send

The type of the associated data for Stores created using [new_store].

Required Methods§

Source

fn new_store(&self, req_id: Option<u64>) -> Result<StoreBundle<Self::StoreData>>

Create a new Store for handling one or more requests.

The req_id parameter is the value passed in the call to ProxyHandler::spawn that created the worker to which the new Store will belong. See that function’s documentation for details.

Source

fn request_timeout(&self) -> Duration

Maximum time allowed to handle a request.

In practice, a guest may be allowed to run up to 2x this time in the case of instance reuse to avoid penalizing concurrent requests being handled by the same instance.

Source

fn idle_instance_timeout(&self) -> Duration

Maximum time to keep an idle instance around before dropping it.

Source

fn max_instance_reuse_count(&self) -> usize

Maximum number of requests to handle using a single instance before dropping it.

Source

fn max_instance_concurrent_reuse_count(&self) -> usize

Maximum number of requests to handle concurrently using a single instance.

Source

fn handle_worker_error(&self, error: Error)

Called when a worker exits with an error.

Implementors§