Skip to main content

orbit_client_pool/
policy.rs

1use std::sync::Arc;
2
3/// Admission consequence derived from one protocol-specific outcome.
4///
5/// This type deliberately contains no HTTP status, header, retry, or decoding
6/// knowledge. The application returns its own error to the triggering caller,
7/// then may apply `Pause` to stop later acquisitions until it repairs the
8/// profile and explicitly resumes the pool.
9#[derive(Clone, Debug, Eq, PartialEq)]
10pub enum PoolDirective {
11    Continue,
12    Pause { reason: Arc<str> }
13}
14
15impl PoolDirective {
16    pub fn pause(reason: impl Into<Arc<str>>) -> Self {
17        Self::Pause { reason: reason.into() }
18    }
19}
20
21/// Application-owned classification from a domain outcome to pool admission.
22///
23/// `O` may be an HTTP response, a protocol frame, or an application result.
24/// The pool never decodes it.
25pub trait ClientPolicy<O>: Send + Sync {
26    fn classify(
27        &self,
28        outcome: &O
29    ) -> PoolDirective;
30}